protected void btnSave_Click(object sender, EventArgs e) { Crime_Remand_InformationObject cbiObject = new Crime_Remand_InformationObject(); CrimeInformationService cisObj = new CrimeInformationService(); try { cbiObject.RefNo = txtRefNo.Text; cbiObject.RemandNo = txtRemandNo.Text; cbiObject.DateofRemand = Convert.ToDateTime(txtDateofRemand.Text); cbiObject.Duration = txtDuration.Text; cbiObject.ReasonofRemand = txtReasonofRemand.Text; cbiObject.CreateBy = User.Identity.Name; cbiObject.CreateDate = DateTime.Now; cbiObject.LastUpdateBy = User.Identity.Name; cbiObject.LastUpdateDate = DateTime.Now; if (cisObj.InsertCrimeRemandInformation(cbiObject)) { Response.Redirect("crime-arrest-information.aspx?refno=" + txtRefNo.Text); } } catch (Exception ex) { ErrorMessage.Text = ex.Message; } }
/// <summary> /// Insert Crime remand information using this fuction /// </summary> /// <returns></returns> public bool InsertCrimeRemandInformation(Crime_Remand_InformationObject criObject) { clsBase baseObj = new clsBase(); string sqlstring = "INSERT INTO [Crime_Remand_Information] ([RefNo],[RemandNo],[DateofRemand]" + ",[Duration],[ReasonofRemand],[CreateBy],[CreateDate],[LastUpdateBy],[LastUpdateDate])" + " VALUES (@RefNo,@RemandNo,@DateofRemand,@Duration,@ReasonofRemand,@CreateBy,@CreateDate,@LastUpdateBy,@LastUpdateDate)"; List<SqlParameter> parametersList = new List<SqlParameter>(); parametersList.Add(new SqlParameter("@RefNo", criObject.RefNo)); parametersList.Add(new SqlParameter("@RemandNo", criObject.RemandNo)); parametersList.Add(new SqlParameter("@DateofRemand", criObject.DateofRemand)); parametersList.Add(new SqlParameter("@Duration", criObject.Duration)); parametersList.Add(new SqlParameter("@ReasonofRemand", criObject.ReasonofRemand)); parametersList.Add(new SqlParameter("@CreateBy", criObject.CreateBy)); parametersList.Add(new SqlParameter("@CreateDate", criObject.CreateDate)); parametersList.Add(new SqlParameter("@LastUpdateBy", criObject.LastUpdateBy)); parametersList.Add(new SqlParameter("@LastUpdateDate", criObject.LastUpdateDate)); return baseObj.InsertData(sqlstring, parametersList); }