Beispiel #1
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=balancestyle>balancestyle</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of accbalancestyle</returns>
 public modAccBalanceStyle GetItem(string balancestyle, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select balance_style,update_user,update_time from acc_balance_style where balance_style='{0}' order by balance_style", balancestyle);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modAccBalanceStyle model = new modAccBalanceStyle();
                 model.BalanceStyle = dalUtility.ConvertToString(rdr["balance_style"]);
                 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);
     }
 }
Beispiel #2
0
 /// <summary>
 /// get all accbalancestyle
 /// <summary>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all accbalancestyle</returns>
 public BindingCollection <modAccBalanceStyle> GetIList(out string emsg)
 {
     try
     {
         BindingCollection <modAccBalanceStyle> modellist = new BindingCollection <modAccBalanceStyle>();
         //Execute a query to read the categories
         string sql = "select balance_style,update_user,update_time from acc_balance_style order by balance_style";
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modAccBalanceStyle model = new modAccBalanceStyle();
                 model.BalanceStyle = dalUtility.ConvertToString(rdr["balance_style"]);
                 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);
     }
 }
Beispiel #3
0
 private void DBGrid_SelectionChanged(object sender, EventArgs e)
 {
     if (DBGrid.CurrentRow != null)
     {
         modAccBalanceStyle mod = (modAccBalanceStyle)DBGrid.CurrentRow.DataBoundItem;
         txtBalanceStyle.Text = mod.BalanceStyle;
         FindText             = mod.BalanceStyle;
     }
 }
Beispiel #4
0
 protected override void Find()
 {
     for (int i = 0; i < DBGrid.Rows.Count; i++)
     {
         modAccBalanceStyle mod = (modAccBalanceStyle)DBGrid.Rows[i].DataBoundItem;
         if (mod.BalanceStyle.CompareTo(FindText) == 0)
         {
             DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
             DBGrid_SelectionChanged(null, null);
             return;
         }
     }
 }
Beispiel #5
0
 protected override bool Save()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(txtBalanceStyle.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("Balance style") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtBalanceStyle.Focus();
             return(false);
         }
         modAccBalanceStyle mod = new modAccBalanceStyle(txtBalanceStyle.Text.Trim(), Util.UserId, DateTime.Now);
         bool ret = false;
         if (_status == 1)
         {
             ret = _dal.Insert(mod, out Util.emsg);
         }
         else if (_status == 2)
         {
             ret = _dal.Update(txtBalanceStyle.Text, mod, out Util.emsg);
         }
         if (ret)
         {
             Util.ChangeStatus(this, true);
             DBGrid.Enabled = true;
             LoadData();
             FindText = mod.BalanceStyle;
             Find();
         }
         return(ret);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Beispiel #6
0
 /// <summary>
 /// insert a accbalancestyle
 /// <summary>
 /// <param name=mod>model object of accbalancestyle</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modAccBalanceStyle mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into acc_balance_style(balance_style,update_user,update_time)values('{0}','{1}',getdate())", mod.BalanceStyle, 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);
     }
 }
Beispiel #7
0
 /// <summary>
 /// update a accbalancestyle
 /// <summary>
 /// <param name=balancestyle>balancestyle</param>
 /// <param name=mod>model object of accbalancestyle</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string balancestyle, modAccBalanceStyle mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update acc_balance_style set update_user='******',update_time=getdate() where balance_style='{1}'", mod.UpdateUser, balancestyle);
         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);
     }
 }