Ejemplo n.º 1
0
 /// <summary>
 /// get all admindeptlist
 /// <summary>
 /// <param name=validonly>status is valid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all admindeptlist</returns>
 public BindingCollection <modAdminDeptList> GetIList(bool validonly, out string emsg)
 {
     try
     {
         BindingCollection <modAdminDeptList> modellist = new BindingCollection <modAdminDeptList>();
         //Execute a query to read the categories
         string getwhere = validonly == true ? "and status=1" : string.Empty;
         string sql      = "select dept_id,dept_desc,status,update_user,update_time from admin_dept_list where 1=1 " + getwhere + "order by dept_id";
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modAdminDeptList model = new modAdminDeptList();
                 model.DeptId     = dalUtility.ConvertToString(rdr["dept_id"]);
                 model.DeptDesc   = dalUtility.ConvertToString(rdr["dept_desc"]);
                 model.Status     = dalUtility.ConvertToInt(rdr["status"]);
                 model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 modellist.Add(model);
             }
         }
         emsg = null;
         return(modellist);
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=deptid>deptid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of admindeptlist</returns>
 public modAdminDeptList GetItem(string deptid, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select dept_id,dept_desc,status,update_user,update_time from admin_dept_list where dept_id='{0}' order by dept_id", deptid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modAdminDeptList model = new modAdminDeptList();
                 model.DeptId     = dalUtility.ConvertToString(rdr["dept_id"]);
                 model.DeptDesc   = dalUtility.ConvertToString(rdr["dept_desc"]);
                 model.Status     = dalUtility.ConvertToInt(rdr["status"]);
                 model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 emsg             = null;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Ejemplo n.º 3
0
 private void DBGrid_SelectionChanged(object sender, EventArgs e)
 {
     if (DBGrid.CurrentRow != null)
     {
         modAdminDeptList mod = (modAdminDeptList)DBGrid.CurrentRow.DataBoundItem;
         txtDeptId.Text          = mod.DeptId;
         txtDeptDesc.Text        = mod.DeptDesc;
         cboStatus.SelectedIndex = Convert.ToInt32(mod.Status);
         FindText = mod.DeptId;
     }
 }
Ejemplo n.º 4
0
 protected override void Find()
 {
     for (int i = 0; i < DBGrid.Rows.Count; i++)
     {
         modAdminDeptList mod = (modAdminDeptList)DBGrid.Rows[i].DataBoundItem;
         if (mod.DeptId.CompareTo(FindText) == 0)
         {
             DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
             DBGrid_SelectionChanged(null, null);
             return;
         }
     }
 }
Ejemplo n.º 5
0
 protected override bool Save()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(txtDeptId.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("dept id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtDeptId.Focus();
             return(false);
         }
         //if (string.IsNullOrEmpty(txtDeptDesc.Text.Trim()))
         //{
         //    MessageBox.Show(clsTranslate.TranslateString("dept desc") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         //    txtDeptDesc.Focus();
         //    return false;
         //}
         modAdminDeptList mod = new modAdminDeptList(txtDeptId.Text.Trim(), txtDeptDesc.Text.Trim(), cboStatus.SelectedIndex, Util.UserId, DateTime.Now);
         bool             ret = false;
         if (_status == 1)
         {
             ret = _dal.Insert(mod, out Util.emsg);
         }
         else if (_status == 2)
         {
             ret = _dal.Update(txtDeptId.Text, mod, out Util.emsg);
         }
         if (ret)
         {
             Util.ChangeStatus(this, true);
             DBGrid.Enabled = true;
             LoadData();
             FindText = mod.DeptId;
             Find();
         }
         return(ret);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// update a admindeptlist
 /// <summary>
 /// <param name=deptid>deptid</param>
 /// <param name=mod>model object of admindeptlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string deptid, modAdminDeptList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update admin_dept_list set dept_desc='{0}',status={1},update_user='******',update_time=getdate() where dept_id='{3}'", mod.DeptDesc, mod.Status, mod.UpdateUser, deptid);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// insert a admindeptlist
 /// <summary>
 /// <param name=mod>model object of admindeptlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modAdminDeptList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into admin_dept_list(dept_id,dept_desc,status,update_user,update_time)values('{0}','{1}',{2},'{3}',getdate())", mod.DeptId, mod.DeptDesc, mod.Status, mod.UpdateUser);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }