protected void btnSave_Click(object sender, EventArgs e) { Crime_ZoneObject cbiObject = new Crime_ZoneObject(); CrimeInformationService cisObj = new CrimeInformationService(); try { cbiObject.RefNo = txtRefNo.Text; cbiObject.Battalion = txtBattalion.Text; cbiObject.District = txtDistrict.Text; cbiObject.PoliceStation = txtPoliceStation.Text; cbiObject.Village = txtVillage.Text; cbiObject.Latitude = txtlatitude.Text; cbiObject.Longitude = txtlongitude.Text; cbiObject.Remarks = txtRemarks.Text; cbiObject.CreateBy = User.Identity.Name; cbiObject.CreateDate = DateTime.Now; cbiObject.LastUpdateBy = User.Identity.Name; cbiObject.LastUpdateDate = DateTime.Now; if (cisObj.InsertCrimeZone(cbiObject)) { Response.Redirect("crime-remand-information.aspx?refno=" + txtRefNo.Text); } } catch (Exception ex) { ErrorMessage.Text = ex.Message; } }
/// <summary> /// Insert Crime zone using this fuction /// </summary> /// <returns></returns> public bool InsertCrimeZone(Crime_ZoneObject czObject) { clsBase baseObj = new clsBase(); string sqlstring = "INSERT INTO [Crime_Zone] ([RefNo],[Battalion],[District],[PoliceStation]" + ",[Village],[Latitude],[Longitude],[Remarks],[CreateBy],[CreateDate],[LastUpdateBy],[LastUpdateDate])" + " VALUES (@RefNo,@Battalion,@District,@PoliceStation,@Village,@Latitude,@Longitude,@Remarks,@CreateBy,@CreateDate,@LastUpdateBy,@LastUpdateDate)"; List<SqlParameter> parametersList = new List<SqlParameter>(); parametersList.Add(new SqlParameter("@RefNo", czObject.RefNo)); parametersList.Add(new SqlParameter("@Battalion", czObject.Battalion)); parametersList.Add(new SqlParameter("@District", czObject.District)); parametersList.Add(new SqlParameter("@PoliceStation", czObject.PoliceStation)); parametersList.Add(new SqlParameter("@Village", czObject.Village)); parametersList.Add(new SqlParameter("@Latitude", czObject.Latitude)); parametersList.Add(new SqlParameter("@Longitude", czObject.Longitude)); parametersList.Add(new SqlParameter("@Remarks", czObject.Remarks)); parametersList.Add(new SqlParameter("@CreateBy", czObject.CreateBy)); parametersList.Add(new SqlParameter("@CreateDate", czObject.CreateDate)); parametersList.Add(new SqlParameter("@LastUpdateBy", czObject.LastUpdateBy)); parametersList.Add(new SqlParameter("@LastUpdateDate", czObject.LastUpdateDate)); return baseObj.InsertData(sqlstring, parametersList); }