protected void SaveData(string IsDelete) { int intFmID = grEmpFamilyInfo.Rows.Count + 1; if (hfIsUpadate.Value == "N") { hfFmId.Value = intFmID.ToString(); } clsEmpFamilyInfo objFam = new clsEmpFamilyInfo(txtEmpID.Text, hfFmId.Value, txtName.Text, txtOccupation.Text, ddlRelation.SelectedValue, txtDob.Text, ddlBloodGroup.SelectedValue, chkIsDependant.Checked == true ? "Y" : "N", Session["USERID"].ToString(), Common.SetDate(DateTime.Now.ToString()), txtInsID.Text.Trim(), txtIncusionDate.Text.Trim(), txtRenewalDate.Text.Trim(), hfFmImage.Value.ToString()); EmpFamilyManager objFamilyMgr = new EmpFamilyManager(); objFamilyMgr.InsertEmpFamily(objFam, hfIsUpadate.Value, IsDelete); if (hfIsUpadate.Value == "N") { lblMsg.Text = "Record Saved Successfully"; } else { lblMsg.Text = "Record Updated Successfully"; } this.EntryMode(false); this.OpenRecord(); }
protected void grEmpFamilyInfo_RowCommand(object sender, GridViewCommandEventArgs e) { GridView _gridView = (GridView)sender; // Get the selected index and the command name int _selectedIndex = int.Parse(e.CommandArgument.ToString()); string _commandName = e.CommandName; _gridView.SelectedIndex = _selectedIndex; switch (_commandName) { case ("DoubleClick"): hfFmId.Value = grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[1].ToString().Trim(); txtName.Text = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[2].Text); ddlRelation.Text = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[3].Text); if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[4].Text.Trim()) != "") { txtDob.Text = grEmpFamilyInfo.SelectedRow.Cells[4].Text; } chkIsDependant.Checked = (grEmpFamilyInfo.SelectedRow.Cells[5].Text == "Y" ? true:false); txtInsID.Text = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[6].Text.Trim()); if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[7].Text.Trim()) != "") { txtIncusionDate.Text = grEmpFamilyInfo.SelectedRow.Cells[7].Text.Trim(); } if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[8].Text.Trim()) != "") { txtRenewalDate.Text = grEmpFamilyInfo.SelectedRow.Cells[8].Text.Trim(); } hfFmImage.Value = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[9].Text.Trim()); if (string.IsNullOrEmpty(hfFmImage.Value) == false) { imgEmp.ImageUrl = "~/EmployeeImage/" + hfFmImage.Value; //hfEmpImage.Value = string.IsNullOrEmpty(tt["EmpPicLoc"].ToString().Trim()) == true ? "" : tt["EmpPicLoc"].ToString().Trim(); } else { imgEmp.ImageUrl = "~/EmployeeImage/NoImage.jpg"; hfFmImage.Value = ""; } this.EntryMode(true); break; case ("RowDeleting"): clsEmpFamilyInfo objFam = new clsEmpFamilyInfo(grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[0].ToString().Trim(), grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[1].ToString().Trim(), grEmpFamilyInfo.SelectedRow.Cells[2].Text, grEmpFamilyInfo.SelectedRow.Cells[3].Text, grEmpFamilyInfo.SelectedRow.Cells[4].Text, grEmpFamilyInfo.SelectedRow.Cells[5].Text, grEmpFamilyInfo.SelectedRow.Cells[6].Text, grEmpFamilyInfo.SelectedRow.Cells[7].Text, Session["USERID"].ToString(), Common.SetDate(DateTime.Now.ToString()), txtInsID.Text.Trim(), txtIncusionDate.Text.Trim(), txtRenewalDate.Text.Trim(), hfFmImage.Value.ToString()); EmpFamilyManager objMgr = new EmpFamilyManager(); objMgr.InsertEmpFamily(objFam, "N", "Y"); if (string.IsNullOrEmpty(hfFmImage.Value) == false) { string FolderPath = ConfigurationManager.AppSettings["EmployeeImagePath"]; string FileName = hfFmImage.Value.ToString(); //string Extension = Path.GetExtension(FileName); string FilePath = Server.MapPath(FolderPath + FileName); FileInfo File = new FileInfo(FilePath); File.Delete(); imgEmp.ImageUrl = ""; hfFmImage.Value = ""; } this.EntryMode(false); this.OpenRecord(); break; } }
public void InsertEmpFamily(clsEmpFamilyInfo objEmpFam, string strIsUpdate, string strIsDelete) { // sproc functionality SqlCommand command = new SqlCommand("proc_Insert_EmpFamilyInfo"); command.CommandType = CommandType.StoredProcedure; SqlParameter p_EmpID = command.Parameters.Add("EmpID", SqlDbType.Char); p_EmpID.Direction = ParameterDirection.Input; p_EmpID.Value = objEmpFam.EmpID; SqlParameter p_FmId = command.Parameters.Add("FmId", SqlDbType.BigInt); p_FmId.Direction = ParameterDirection.Input; p_FmId.Value = objEmpFam.FmId; SqlParameter p_fmName = command.Parameters.Add("fmName", SqlDbType.VarChar); p_fmName.Direction = ParameterDirection.Input; p_fmName.Value = objEmpFam.fmName; SqlParameter p_Fmocc = command.Parameters.Add("Fmocc", SqlDbType.VarChar); p_Fmocc.Direction = ParameterDirection.Input; p_Fmocc.Value = objEmpFam.Fmocc; SqlParameter p_frRelation = command.Parameters.Add("frRelation", SqlDbType.VarChar); p_frRelation.Direction = ParameterDirection.Input; p_frRelation.Value = objEmpFam.frRelation; SqlParameter p_FmDoB = command.Parameters.Add("FmDoB", DBNull.Value); p_FmDoB.Direction = ParameterDirection.Input; p_FmDoB.IsNullable = true; if (objEmpFam.FmDoB != "") { p_FmDoB.Value = Common.ReturnDate(objEmpFam.FmDoB); } SqlParameter p_FmBloodGrp = command.Parameters.Add("FmBloodGrp", SqlDbType.VarChar); p_FmBloodGrp.Direction = ParameterDirection.Input; p_FmBloodGrp.Value = objEmpFam.FmBloodGrp; SqlParameter p_Isdependent = command.Parameters.Add("Isdependent", SqlDbType.Char); p_Isdependent.Direction = ParameterDirection.Input; p_Isdependent.Value = objEmpFam.Isdependent; SqlParameter p_InsertedBy = command.Parameters.Add("InsertedBy", SqlDbType.VarChar); p_InsertedBy.Direction = ParameterDirection.Input; p_InsertedBy.Value = objEmpFam.InsertedBy; SqlParameter p_InsertedDate = command.Parameters.Add("InsertedDate", SqlDbType.DateTime); p_InsertedDate.Direction = ParameterDirection.Input; p_InsertedDate.Value = objEmpFam.InsertedDate; SqlParameter p_IsUpdate = command.Parameters.Add("IsUpdate", SqlDbType.Char); p_IsUpdate.Direction = ParameterDirection.Input; p_IsUpdate.Value = strIsUpdate; SqlParameter p_IsDelete = command.Parameters.Add("IsDelete", SqlDbType.Char); p_IsDelete.Direction = ParameterDirection.Input; p_IsDelete.Value = strIsDelete; SqlParameter p_InsuranceID = command.Parameters.Add("InsuranceID", SqlDbType.VarChar); p_InsuranceID.Direction = ParameterDirection.Input; p_InsuranceID.Value = objEmpFam.InsuranceID; SqlParameter p_InclusionDate = command.Parameters.Add("InclusionDate", DBNull.Value); p_InclusionDate.Direction = ParameterDirection.Input; p_InclusionDate.IsNullable = true; if (string.IsNullOrEmpty(objEmpFam.InclusionDate) == false) { p_InclusionDate.Value = Common.ReturnDate(objEmpFam.InclusionDate); } SqlParameter p_RenewalDate = command.Parameters.Add("RenewalDate", DBNull.Value); p_RenewalDate.Direction = ParameterDirection.Input; p_RenewalDate.IsNullable = true; if (string.IsNullOrEmpty(objEmpFam.RenewalDate) == false) { p_RenewalDate.Value = Common.ReturnDate(objEmpFam.RenewalDate); } SqlParameter p_EmpPicLoc = command.Parameters.Add("EmpPicLoc", SqlDbType.VarChar); p_EmpPicLoc.Direction = ParameterDirection.Input; p_EmpPicLoc.Value = objEmpFam.EmpPicLoc; try { objDC.ExecuteQuery(command); } catch (Exception ex) { throw (ex); } finally { command = null; } }