private void SaveData() { string strAllowId = ""; try { if (hfIsUpdate.Value == "N") { strAllowId = Common.getMaxId("ChildEduAllowance", "AllowanceId"); } else { strAllowId = hfID.Value.ToString(); } string strDOB = ""; if (string.IsNullOrEmpty(txtDOB.Text.Trim()) == false) { strDOB = Common.ReturnDate(txtDOB.Text.Trim()); } Payroll_ChildEduAllowannce objclsEduAllow = new Payroll_ChildEduAllowannce(); objclsEduAllow.AllowanceID = strAllowId; objclsEduAllow.EmpId = txtEmpID.Text.Trim(); objclsEduAllow.ChildName = txtChildName.Text.Trim(); objclsEduAllow.ChildDOB = strDOB; objclsEduAllow.Gender = ddlGender.SelectedValue.ToString(); objclsEduAllow.Age = txtAge.Text; objclsEduAllow.Amount = txtAmount.Text; objclsEduAllow.VMONTH = ddlMonth.SelectedValue.Trim(); objclsEduAllow.VYEAR = ddlYear.SelectedValue.Trim(); objclsEduAllow.InsertedBy = Session["USERID"].ToString(); objclsEduAllow.InsertedDate = Common.SetDateTime(DateTime.Now.ToString()); objVarMgr.InsertChildEduAllowance(objclsEduAllow, hfIsUpdate.Value, "N"); if (hfIsUpdate.Value == "N") { lblMsg.Text = "Record Saved Successfully"; } else if (hfIsUpdate.Value == "Y") { lblMsg.Text = "Record Updated Successfully"; } else { lblMsg.Text = "Record Deleted Successfully"; } this.EntryMode(false); this.OpenRecord(); this.ClearControls(); } catch (Exception ex) { lblMsg.Text = ""; throw (ex); } }
public void InsertChildEduAllowance(Payroll_ChildEduAllowannce objEduAllow, string IsUpdate, string IsDelete) { SqlCommand cmd = new SqlCommand("proc_Payroll_Insert_ChildEduAllowance"); cmd.CommandType = CommandType.StoredProcedure; SqlParameter p_AllowanceID = cmd.Parameters.Add("AllowanceID", SqlDbType.BigInt); p_AllowanceID.Direction = ParameterDirection.Input; p_AllowanceID.Value = objEduAllow.AllowanceID; SqlParameter p_EmpId = cmd.Parameters.Add("EmpId", SqlDbType.VarChar); p_EmpId.Direction = ParameterDirection.Input; p_EmpId.Value = objEduAllow.EmpId; SqlParameter p_ChildName = cmd.Parameters.Add("ChildName", SqlDbType.VarChar); p_ChildName.Direction = ParameterDirection.Input; p_ChildName.Value = objEduAllow.ChildName; SqlParameter p_ChildDOB = cmd.Parameters.Add("ChildDOB", DBNull.Value); p_ChildDOB.Direction = ParameterDirection.Input; p_ChildDOB.IsNullable = true; if (objEduAllow.ChildDOB != "") { p_ChildDOB.Value = objEduAllow.ChildDOB; } SqlParameter p_Gender = cmd.Parameters.Add("Gender", SqlDbType.Char); p_Gender.Direction = ParameterDirection.Input; p_Gender.Value = objEduAllow.Gender; SqlParameter p_Age = cmd.Parameters.Add("Age", DBNull.Value); p_Age.Direction = ParameterDirection.Input; p_Age.IsNullable = true; if (objEduAllow.Age != "") { p_Age.Value = objEduAllow.Age; } SqlParameter p_Amount = cmd.Parameters.Add("Amount", DBNull.Value); p_Amount.Direction = ParameterDirection.Input; p_Amount.IsNullable = true; if (objEduAllow.Amount != "") { p_Amount.Value = objEduAllow.Amount; } SqlParameter p_VMONTH = cmd.Parameters.Add("VMONTH", SqlDbType.BigInt); p_VMONTH.Direction = ParameterDirection.Input; p_VMONTH.Value = objEduAllow.VMONTH; SqlParameter p_VYEAR = cmd.Parameters.Add("VYEAR", SqlDbType.BigInt); p_VYEAR.Direction = ParameterDirection.Input; p_VYEAR.Value = objEduAllow.VYEAR; SqlParameter p_InsertedBy = cmd.Parameters.Add("InsertedBy", SqlDbType.VarChar); p_InsertedBy.Direction = ParameterDirection.Input; p_InsertedBy.Value = objEduAllow.InsertedBy; SqlParameter p_UpdatedDate = cmd.Parameters.Add("InsertedDate", SqlDbType.DateTime); p_UpdatedDate.Direction = ParameterDirection.Input; p_UpdatedDate.Value = objEduAllow.InsertedDate; SqlParameter p_IsUpdate = cmd.Parameters.Add("IsUpdate", SqlDbType.Char); p_IsUpdate.Direction = ParameterDirection.Input; p_IsUpdate.Value = IsUpdate; SqlParameter p_IsDelete = cmd.Parameters.Add("IsDelete", SqlDbType.Char); p_IsDelete.Direction = ParameterDirection.Input; p_IsDelete.Value = IsDelete; try { objDC.ExecuteQuery(cmd); } catch (Exception ex) { throw (ex); } finally { cmd = null; } }