Ejemplo n.º 1
0
 /// <summary>
 /// get all otherreceivableobject
 /// <summary>
 /// <param name=objectname>objectname</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all otherreceivableobject</returns>
 public BindingCollection <modOtherReceivableObject> GetIList(string objectname, out string emsg)
 {
     try
     {
         BindingCollection <modOtherReceivableObject> modellist = new BindingCollection <modOtherReceivableObject>();
         //Execute a query to read the categories
         string sql = string.Format("select object_name,status,currency,link_man,addr,tel,remark,update_user,update_time from other_receivable_object where object_name='{0}' order by object_name", objectname);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modOtherReceivableObject model = new modOtherReceivableObject();
                 model.ObjectName = dalUtility.ConvertToString(rdr["object_name"]);
                 model.Status     = dalUtility.ConvertToInt(rdr["status"]);
                 model.Currency   = dalUtility.ConvertToString(rdr["currency"]);
                 model.LinkMan    = dalUtility.ConvertToString(rdr["link_man"]);
                 model.Addr       = dalUtility.ConvertToString(rdr["addr"]);
                 model.Tel        = dalUtility.ConvertToString(rdr["tel"]);
                 model.Remark     = dalUtility.ConvertToString(rdr["remark"]);
                 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
 protected override void Find()
 {
     for (int i = 0; i < DBGrid.Rows.Count; i++)
     {
         modOtherReceivableObject mod = (modOtherReceivableObject)DBGrid.Rows[i].DataBoundItem;
         if (mod.ObjectName.CompareTo(FindText) == 0)
         {
             DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
             DBGrid_SelectionChanged(null, null);
             return;
         }
     }
 }
Ejemplo n.º 3
0
 protected override bool Save()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(txtObjectName.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("cust type") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtObjectName.Focus();
             return(false);
         }
         modOtherReceivableObject mod = new modOtherReceivableObject();
         mod.ObjectName = txtObjectName.Text.Trim();
         mod.Status     = cboStatus.SelectedIndex;
         mod.Currency   = cboCurrency.SelectedValue.ToString();
         mod.LinkMan    = txtLinkMan.Text.Trim();
         mod.Addr       = txtAddr.Text.Trim();
         mod.Tel        = txtTel.Text.Trim();
         mod.Remark     = txtRemark.Text.Trim();
         mod.UpdateUser = Util.UserId;
         bool ret = false;
         if (_status == 1)
         {
             ret = _dal.Insert(mod, out Util.emsg);
         }
         else if (_status == 2)
         {
             ret = _dal.Update(txtObjectName.Text, mod, out Util.emsg);
         }
         if (ret)
         {
             Util.ChangeStatus(this, true);
             DBGrid.Enabled = true;
             LoadData();
             FindText = mod.ObjectName;
             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.º 4
0
 private void DBGrid_SelectionChanged(object sender, EventArgs e)
 {
     if (DBGrid.CurrentRow != null)
     {
         modOtherReceivableObject mod = (modOtherReceivableObject)DBGrid.CurrentRow.DataBoundItem;
         txtObjectName.Text        = mod.ObjectName;
         cboStatus.SelectedIndex   = Convert.ToInt32(mod.Status);
         cboCurrency.SelectedValue = mod.Currency;
         txtLinkMan.Text           = mod.LinkMan;
         txtAddr.Text   = mod.Addr;
         txtTel.Text    = mod.Tel;
         txtRemark.Text = mod.Remark;
         FindText       = mod.ObjectName;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// update a otherreceivableobject
 /// <summary>
 /// <param name=objectname>objectname</param>
 /// <param name=mod>model object of otherreceivableobject</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string objectname, modOtherReceivableObject mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update other_receivable_object set status={0},link_man='{1}',addr='{2}',tel='{3}',remark='{4}',update_user='******',update_time=getdate() where object_name='{6}'", mod.Status, mod.LinkMan, mod.Addr, mod.Tel, mod.Remark, mod.UpdateUser, objectname);
         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.º 6
0
 /// <summary>
 /// insert a otherreceivableobject
 /// <summary>
 /// <param name=mod>model object of otherreceivableobject</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modOtherReceivableObject mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into other_receivable_object(object_name,status,link_man,addr,tel,remark,update_user,update_time,currency)values('{0}',{1},'{2}','{3}','{4}','{5}','{6}',getdate(),'{7}')", mod.ObjectName, mod.Status, mod.LinkMan, mod.Addr, mod.Tel, mod.Remark, mod.UpdateUser, mod.Currency);
         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
        private void LoadData()
        {
            if (prepared == false)
            {
                return;
            }
            if (DBGrid.CurrentRow == null)
            {
                return;
            }

            switch (cboBookType.SelectedIndex)
            {
            case 0:      //应收
                modCustomerSimpleList modCust = (modCustomerSimpleList)DBGrid.CurrentRow.DataBoundItem;
                dalAccReceivableList  dalRec  = new dalAccReceivableList();
                BindingCollection <modReceivableBook> listRec = dalRec.GetReceivableBook(modCust.CustId, dtpFrom.Value, dtpTo.Value, out Util.emsg);
                DBGrid2.DataSource = listRec;
                break;

            case 1:      //应付
                modVendorList     modVendor = (modVendorList)DBGrid.CurrentRow.DataBoundItem;
                dalAccPayableList dalPay    = new dalAccPayableList();
                BindingCollection <modPayableBook> listPay = dalPay.GetPayableBook(modVendor.VendorName, dtpFrom.Value, dtpTo.Value, out Util.emsg);
                DBGrid2.DataSource = listPay;
                break;

            case 2:      //其它应收
                modOtherReceivableObject modObjRec = (modOtherReceivableObject)DBGrid.CurrentRow.DataBoundItem;
                dalAccOtherReceivable    dalORec   = new dalAccOtherReceivable();
                BindingCollection <modOtherReceivableBook> listORec = dalORec.GetOtherReceivableBook(modObjRec.ObjectName, dtpFrom.Value, dtpTo.Value, out Util.emsg);
                DBGrid2.DataSource = listORec;
                break;

            case 3:      //其它应付
                modOtherPayableObject modObjPay = (modOtherPayableObject)DBGrid.CurrentRow.DataBoundItem;
                dalAccOtherPayable    dalOPay   = new dalAccOtherPayable();
                BindingCollection <modOtherPayableBook> listOPay = dalOPay.GetOtherPayableBook(modObjPay.ObjectName, dtpFrom.Value, dtpTo.Value, out Util.emsg);
                DBGrid2.DataSource = listOPay;
                break;

            case 4:      //现金银行
                modAccBankAccount modCash = (modAccBankAccount)DBGrid.CurrentRow.DataBoundItem;
                dalAccReport      dalCash = new dalAccReport();
                BindingCollection <modAccCredenceBook> listCash = dalCash.GetCashAndBankBook(modCash.AccountNo, dtpFrom.Value, dtpTo.Value, out Util.emsg);
                DBGrid2.DataSource = listCash;
                break;
            }
            for (int i = 0; i < DBGrid2.RowCount; i++)
            {
                if (DBGrid2.Rows[i].Cells["AccSeq"].Value.ToString() == "本月合计")
                {
                    DBGrid2.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                }
            }
            if (DBGrid2.RowCount > 0)
            {
                DBGrid2.Columns[0].Visible = false;

                DBGrid2.Columns["StartMny"].Width  = 120;
                DBGrid2.Columns["AddingMny"].Width = 120;
                DBGrid2.Columns["PaidMny"].Width   = 120;
                DBGrid2.Columns["EndMny"].Width    = 120;

                DBGrid2.Columns["StartMny"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
                DBGrid2.Columns["AddingMny"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGrid2.Columns["PaidMny"].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleRight;
                DBGrid2.Columns["EndMny"].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.MiddleRight;
            }
        }