public static CustomList <DemoEmpMaster> GetSelectedemp(int empCode) { ConnectionManager conManager = new ConnectionManager(ConnectionName.HR); CustomList <DemoEmpMaster> empCollection = new CustomList <DemoEmpMaster>(); IDataReader reader = null; String sql = "select * from DemoEmp where empCode= " + empCode + ""; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { DemoEmpMaster newemp = new DemoEmpMaster(); newemp.SetData(reader); empCollection.Add(newemp); } empCollection.InsertSpName = "spInsertDemoemp"; empCollection.UpdateSpName = "spUpdateDemoemp"; empCollection.DeleteSpName = "spDeleteDemoemp"; return(empCollection); } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
private void SetDataFromControlToObj(ref ASL.DATA.CustomList <DemoEmpMaster> lstemp) { ASL.Hr.DAO.DemoEmpMaster obj = lstemp[0]; if (txtempCode.Visible.IsTrue()) { obj.empCode = Convert.ToInt32(txtempCode.Text); } else { obj.empCode = Convert.ToInt32(ddlempCodeKey.SelectedItem.Text); } obj.empName = txtempName.Text; obj.Doj = Convert.ToDateTime(txtdojDate.Text); obj.Doc = Convert.ToDateTime(txtdocDate.Text); }
protected void btnSave_Click(object sender, EventArgs e) { #region Using Class try { CustomList <ASL.Hr.DAO.DemoEmpMaster> lstemp = (CustomList <ASL.Hr.DAO.DemoEmpMaster>)_empMasterForSave; if (lstemp.IsNull() || lstemp.Count == 0) { ASL.Hr.DAO.DemoEmpMaster newemp = new ASL.Hr.DAO.DemoEmpMaster(); lstemp.Add(newemp); } SetDataFromControlToObj(ref lstemp); empManager.SaveEmp(ref lstemp); txtempCode.Visible = false; ddlempCodeKey.Visible = true; _emp = empManager.GetAllempMaster(); ddlempCodeKey.DataSource = _emp; ddlempCodeKey.DataTextField = "empCode"; ddlempCodeKey.DataValueField = "empCode"; ddlempCodeKey.DataBind(); ddlempCodeKey.Items.Insert(0, new ListItem(String.Empty, String.Empty)); ddlempCodeKey.SelectedIndex = 0; ((PageBase)this.Page).SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); ddlempCodeKey.SelectedValue = lstemp[0].empCode.ToString(); } catch (SqlException ex) { ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex)); } catch (Exception ex) { ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getExceptionMessage(ex)); } #endregion }