The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Big Heart (1) [Avatar] Offline
#1
this is my stored procedure and c# code, Patient_ID_NO is not inserting the value it is inserting NULL, and i want to shaoe idcount value in message box. how can i do this process.


ALTER PROCEDURE [dbo].[Transaction]
(

@Patient nvarchar(50),
@E_TO nvarchar(50),
@R_type int,
@User_id uniqueidentifier,
@ReportType nvarchar(50),
@Patient_no int,
@Patient_ID_NO numeric(10,0),
@idcount numeric(18,0)=NULL output
)
AS
BEGIN

declare @tempid numeric(18,0)
set @tempid = 0;
declare @idcnt numeric(18,0)
select @idcnt =isnull( max(idcount),0) from Transactions where year(R_date)=year(getdate())
if (@idcnt =0)
set @tempid=1
else
set @tempid = @idcnt +1
INSERT INTO dbo.Transactions
(
Patient,E_TO,R_date,R_from,[User_id],
report_type,Patient_no,Patient_ID_NO,idcount
)
values
(
@Patient,@E_TO,getdate(),@R_type,@User_id,@ReportType,@Patient_no,@Patient_ID_NO,@tempid
)
END

public static void Message(String message, Control cntrl)
{
ScriptManager.RegisterStartupScript(cntrl, cntrl.GetType(), "alert"
, "alert('" + message + "');", true);
}
protected void Button1_Click(object sender, EventArgs e)
{
if (PatID_NO.Text != "")
{
SIDC a = new SIDC();
int n;
n = a.valid_re_int(PatID_NO.Text);
if (n > 3)
{
Message("Error as well as make sure identification number"", this);
return;
}
else
PatID_NO.Focus();
}

else

PatID_NO.Focus();
try
{
if (NameTxtBx.Text == "" || ToTxtBx0.Text == "" || DropDownList1.SelectedIndex == 0 || RadioButtonList2.SelectedIndex == -1 || ( PatID_NO.Text == ""smilie|| (Convert.ToUInt64(PatNo.Text) <= 0) || (Convert.ToUInt64(PatNo.Text) > 200000000))
{
Message("Error: Please make sure that all fields are entered correctly", this);
return;
}
else
{
try
{
string Patient_name = NameTxtBx.Text, Export_TO = ToTxtBx0.Text, repType = RadioButtonList2.SelectedValue ;

int PatNoVal;
PatNoVal = Convert.ToInt32(PatNo.Text);
PatNoVal = int.Parse(PatNo.Text);
DateTime today = Convert.ToDateTime(DateTime.Now.ToShortDateString());
System.Nullable<decimal> idcount = null;
int? replay_To_type = Int16.Parse(DropDownList1.SelectedValue);
try

{

TransDataContext db = new TransDataContext();

try
{

var q = db.Transaction(Patient_name, Export_TO,replay_To_type,null,repType,PatNoVal,PatID,ref idcount);
//var q = db.Transaction(Patient_name, Export_TO, today, replay_To_type, null, repType, PatNoVal, idcount );

foreach (Transaction Transaction in Transactions)
{
Response.Write("your id is" + Transaction.idcount + "
");
}

}
catch
{
Message("block 3:There is an error in the entry form required, please contact the Department of Computer", this);

}

}
catch
{
Message("block 2: ERROR CONTACT YOUR SYSTEM ADMINISTRATOR", this);
}

PatNo.Text = "";
NameTxtBx.Text = "";
ToTxtBx0.Text = "";
DropDownList1.SelectedIndex = -1;
RadioButtonList2.SelectedIndex = -1;

}
catch
{
Message("خطأ : ERROR 20", this);
}

}
}
catch
{
Message("Error: Make sure you enter the data correctly ", this);
}
}

protected void DropDownList1_DataBound(object sender, EventArgs e)
{
DropDownList1.Items.Insert(0, "--Select One--");
}

public IEnumerable<Transaction> Transactions { get; set; }

public decimal? PatID { get; set; }
}
}