コード例 #1
0
        private void mnuPurchaseList_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (DBGrid.CurrentRow == null)
                {
                    return;
                }

                modCustomerOrderList mod = (modCustomerOrderList)DBGrid.CurrentRow.DataBoundItem;
                dalPurchaseList      dal = new dalPurchaseList();
                BindingCollection <modVPurchaseDetail> list = dal.GetVDetail(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, mod.ProductId, string.Empty, mod.CustOrderNo, string.Empty, string.Empty, out Util.emsg);
                if (list != null && list.Count > 0)
                {
                    frmViewList frm = new frmViewList();
                    frm.InitViewList(clsTranslate.TranslateString("Purchase List"), list);
                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show(clsTranslate.TranslateString("No data found!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #2
0
 private void mnuCopyItem_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modCustomerOrderList  mod = (modCustomerOrderList)DBGrid.CurrentRow.DataBoundItem;
         EditCustomerOrderList frm = new EditCustomerOrderList();
         frm.CopyItem(mod);
         if (frm.ShowDialog() == DialogResult.OK)
         {
             LoadData();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
コード例 #3
0
 private void toolDel_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to delete it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         modCustomerOrderList mod = _dal.GetItem(Convert.ToInt32(DBGrid.CurrentRow.Cells[0].Value), out Util.emsg);
         bool ret = _dal.Delete(mod.Id, out Util.emsg);
         if (ret)
         {
             LoadData();
         }
         else
         {
             MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
コード例 #4
0
        public void ImportOrder(int id)
        {
            dalCustomerOrderList dal = new dalCustomerOrderList();
            modCustomerOrderList mod = dal.GetItem(id, out Util.emsg);

            if (mod != null)
            {
                _action               = "NEW";
                txtId.Text            = "0";
                dtpFormDate.Value     = DateTime.Today;
                dtpRequireDate.Value  = mod.RequireDate;
                txtVendorOrderNo.Text = mod.CustOrderNo;
                txtCurrency.Text      = mod.Currency;
                //txtVendorName.Text = mod.VendorName;
                txtPayMethod.Text   = mod.PayMethod;
                txtPurchaseMan.Text = Util.UserId;
                txtUnitNo.Text      = mod.UnitNo;
                txtQty.Text         = mod.Qty.ToString();
                //txtPrice.Text = mod.Price.ToString();
                txtProductName.Tag  = mod.ProductId;
                txtProductName.Text = mod.ProductName;
                txtSize.Text        = mod.Size.ToString();
                txtRemark.Text      = mod.Remark;
            }
        }
コード例 #5
0
 public void CopyItem(modCustomerOrderList mod)
 {
     try
     {
         this.Cursor          = Cursors.WaitCursor;
         _action              = "NEW";
         txtId.Text           = "0";
         dtpFormDate.Value    = mod.FormDate;
         dtpRequireDate.Value = mod.RequireDate;
         txtCustOrderNo.Text  = mod.CustOrderNo;
         txtCurrency.Text     = mod.Currency;
         txtCustName.Tag      = mod.CustId;
         txtCustName.Text     = mod.CustName;
         txtPayMethod.Text    = mod.PayMethod;
         txtSalesMan.Text     = mod.SalesMan;
         txtUnitNo.Text       = mod.UnitNo;
         //txtQty.Text = mod.Qty.ToString();
         //txtPrice.Text = mod.Price.ToString();
         //txtProductName.Tag = mod.ProductId;
         //txtProductName.Text = mod.ProductName;
         //txtSize.Text = mod.Size.ToString();
         txtRemark.Text = mod.Remark;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
コード例 #6
0
ファイル: DALCUSTOMERORDERLIST.cs プロジェクト: 100009/hberp
        public BindingCollection <modCustomerOrderList> GetIList(string idlist, out string emsg)
        {
            try
            {
                BindingCollection <modCustomerOrderList> modellist = new BindingCollection <modCustomerOrderList>();
                //Execute a query to read the categories
                string idtwhere = string.Empty;
                if (!string.IsNullOrEmpty(idlist) && idlist.CompareTo("ALL") != 0)
                {
                    idtwhere = "and id in ('" + idlist.Replace(",", "','") + "') ";
                }

                string sql = "select id,cust_id,cust_name,cust_order_no,form_date,require_date,pay_method,sales_man,product_id,product_name,specify,size,unit_no,qty,price,remark,currency,update_user,update_time "
                             + "from customer_order_list where 1=1 " + idtwhere + "order by id desc";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modCustomerOrderList model = new modCustomerOrderList();
                        model.Id          = dalUtility.ConvertToInt(rdr["id"]);
                        model.CustId      = dalUtility.ConvertToString(rdr["cust_id"]);
                        model.CustName    = dalUtility.ConvertToString(rdr["cust_name"]);
                        model.CustOrderNo = dalUtility.ConvertToString(rdr["cust_order_no"]);
                        model.FormDate    = dalUtility.ConvertToDateTime(rdr["form_date"]);
                        model.RequireDate = dalUtility.ConvertToDateTime(rdr["require_date"]);
                        model.PayMethod   = dalUtility.ConvertToString(rdr["pay_method"]);
                        model.SalesMan    = dalUtility.ConvertToString(rdr["sales_man"]);
                        model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                        model.ProductName = dalUtility.ConvertToString(rdr["product_name"]);
                        model.Specify     = dalUtility.ConvertToString(rdr["specify"]);
                        model.Size        = dalUtility.ConvertToDecimal(rdr["size"]);
                        model.UnitNo      = dalUtility.ConvertToString(rdr["unit_no"]);
                        model.Qty         = dalUtility.ConvertToDecimal(rdr["qty"]);
                        model.Price       = dalUtility.ConvertToDecimal(rdr["price"]);
                        model.SumMny      = model.Qty * model.Price;
                        model.ShipQty     = GetShipQty(model.CustId, model.CustOrderNo, model.ProductId);
                        model.Differ      = model.Qty - model.ShipQty;
                        model.Remark      = dalUtility.ConvertToString(rdr["remark"]);
                        model.Currency    = dalUtility.ConvertToString(rdr["currency"]);
                        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);
            }
        }
コード例 #7
0
ファイル: DALCUSTOMERORDERLIST.cs プロジェクト: 100009/hberp
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=id>id</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of customerorderlist</returns>
 public modCustomerOrderList GetItem(int id, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select id,cust_id,cust_name,cust_order_no,form_date,require_date,pay_method,sales_man,product_id,product_name,specify,size,unit_no,qty,price,remark,currency,update_user,update_time from customer_order_list where id={0} order by id", id);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modCustomerOrderList model = new modCustomerOrderList();
                 model.Id          = dalUtility.ConvertToInt(rdr["id"]);
                 model.CustId      = dalUtility.ConvertToString(rdr["cust_id"]);
                 model.CustName    = dalUtility.ConvertToString(rdr["cust_name"]);
                 model.CustOrderNo = dalUtility.ConvertToString(rdr["cust_order_no"]);
                 model.FormDate    = dalUtility.ConvertToDateTime(rdr["form_date"]);
                 model.RequireDate = dalUtility.ConvertToDateTime(rdr["require_date"]);
                 model.PayMethod   = dalUtility.ConvertToString(rdr["pay_method"]);
                 model.SalesMan    = dalUtility.ConvertToString(rdr["sales_man"]);
                 model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                 model.ProductName = dalUtility.ConvertToString(rdr["product_name"]);
                 model.Specify     = dalUtility.ConvertToString(rdr["specify"]);
                 model.Size        = dalUtility.ConvertToDecimal(rdr["size"]);
                 model.UnitNo      = dalUtility.ConvertToString(rdr["unit_no"]);
                 model.Qty         = dalUtility.ConvertToDecimal(rdr["qty"]);
                 model.SumMny      = model.Qty * model.Price;
                 model.ShipQty     = GetShipQty(model.CustId, model.CustOrderNo, model.ProductId);
                 model.Differ      = model.Qty - model.ShipQty;
                 model.Price       = dalUtility.ConvertToDecimal(rdr["price"]);
                 model.Remark      = dalUtility.ConvertToString(rdr["remark"]);
                 model.Currency    = dalUtility.ConvertToString(rdr["currency"]);
                 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);
     }
 }
コード例 #8
0
ファイル: DALCUSTOMERORDERLIST.cs プロジェクト: 100009/hberp
 /// <summary>
 /// update a customerorderlist
 /// <summary>
 /// <param name=id>id</param>
 /// <param name=mod>model object of customerorderlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(int id, modCustomerOrderList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update customer_order_list set cust_id='{0}',cust_name='{1}',cust_order_no='{2}',form_date='{3}',require_date='{4}',pay_method='{5}',sales_man='{6}',product_id='{7}',product_name='{8}',specify='{9}',size={10},unit_no='{11}',qty={12},price={13},currency='{14}',remark='{15}',update_user='******',update_time=getdate() where id={17}", mod.CustId, mod.CustName, mod.CustOrderNo, mod.FormDate, mod.RequireDate, mod.PayMethod, mod.SalesMan, mod.ProductId, mod.ProductName, mod.Specify, mod.Size, mod.UnitNo, mod.Qty, mod.Price, mod.Currency, mod.Remark, mod.UpdateUser, id);
         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);
     }
 }
コード例 #9
0
ファイル: DALCUSTOMERORDERLIST.cs プロジェクト: 100009/hberp
 /// <summary>
 /// insert a customerorderlist
 /// <summary>
 /// <param name=mod>model object of customerorderlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modCustomerOrderList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into customer_order_list(cust_id,cust_name,cust_order_no,form_date,require_date,pay_method,sales_man,product_id,product_name,specify,size,unit_no,qty,price,currency,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',{10},'{11}',{12},{13},'{14}','{15}','{16}',getdate())", mod.CustId, mod.CustName, mod.CustOrderNo, mod.FormDate, mod.RequireDate, mod.PayMethod, mod.SalesMan, mod.ProductId, mod.ProductName, mod.Specify, mod.Size, mod.UnitNo, mod.Qty, mod.Price, mod.Currency, mod.Remark, 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);
     }
 }
コード例 #10
0
 public void EditItem(int id)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         _action     = "EDIT";
         modCustomerOrderList mod = _dal.GetItem(id, out Util.emsg);
         if (mod != null)
         {
             txtId.Text           = id.ToString();
             dtpFormDate.Value    = mod.FormDate;
             dtpRequireDate.Value = mod.RequireDate;
             txtCustOrderNo.Text  = mod.CustOrderNo;
             txtCurrency.Text     = mod.Currency;
             txtCustName.Tag      = mod.CustId;
             txtCustName.Text     = mod.CustName;
             txtPayMethod.Text    = mod.PayMethod;
             txtSalesMan.Text     = mod.SalesMan;
             txtUnitNo.Text       = mod.UnitNo;
             txtQty.Text          = mod.Qty.ToString();
             txtPrice.Text        = mod.Price.ToString();
             txtProductName.Tag   = mod.ProductId;
             txtProductName.Text  = mod.ProductName;
             txtSize.Text         = mod.Size.ToString();
             txtRemark.Text       = mod.Remark;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
コード例 #11
0
 private void ShowColor()
 {
     if (DBGrid.RowCount == 0)
     {
         return;
     }
     for (int i = 0; i < DBGrid.RowCount; i++)
     {
         modCustomerOrderList mod = (modCustomerOrderList)DBGrid.Rows[i].DataBoundItem;
         if (mod.Qty > 0)
         {
             decimal ratio   = mod.ShipQty / mod.Qty;
             decimal ratio_f = Convert.ToDecimal(clsLxms.GetParameterValue("ORDER_FINISHED_RATIO"));
             decimal ratio_o = Convert.ToDecimal(clsLxms.GetParameterValue("ORDER_OVERFLOW_RATIO"));
             if (ratio < ratio_f)
             {
                 if (mod.RequireDate > DateTime.Today)
                 {
                     DBGrid.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
                 }
                 else
                 {
                     DBGrid.Rows[i].DefaultCellStyle.ForeColor = Color.Blue;
                 }
             }
             else if (ratio <= ratio_o)
             {
                 DBGrid.Rows[i].DefaultCellStyle.ForeColor = Color.DarkGray;
             }
             else
             {
                 DBGrid.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
             }
         }
     }
 }
コード例 #12
0
        private void mnuNewVendorOrderList_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (DBGrid.CurrentRow == null)
                {
                    return;
                }

                string selectionlist = string.Empty;

                dalVendorList dalvendor = new dalVendorList();
                BindingCollection <modVendorList> listvendor = dalvendor.GetIList("1", string.Empty, out Util.emsg);
                if (listvendor != null)
                {
                    frmSingleSelect frm = new frmSingleSelect();
                    frm.InitViewList("请选择供应商", listvendor, "VendorName", "VendorName", ComboBoxStyle.DropDown);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        modVendorList modvendor = dalvendor.GetItem(Util.retValue1, out Util.emsg);
                        BindingCollection <modVendorOrderList> list = new BindingCollection <modVendorOrderList>();
                        if (DBGrid.SelectedRows.Count == 0)
                        {
                            modCustomerOrderList modco = (modCustomerOrderList)DBGrid.CurrentRow.DataBoundItem;
                            modVendorOrderList   mod   = new modVendorOrderList();
                            mod.Id          = 0;
                            mod.FormDate    = DateTime.Today;
                            mod.RequireDate = DateTime.Today;
                            //mod.VendorOrderNo = modco.CustOrderNo;
                            mod.Remark      = modco.CustName + ": " + modco.CustOrderNo;
                            mod.VendorName  = Util.retValue1;
                            mod.PayMethod   = string.Empty;
                            mod.PurchaseMan = Util.UserId;
                            mod.ProductId   = modco.ProductId;
                            mod.ProductName = modco.ProductName;
                            if (clsLxms.GetProductSizeFlag(mod.ProductId) == 0)
                            {
                                mod.Size = 1;
                            }
                            else
                            {
                                mod.Size = modco.Size;
                            }
                            mod.Currency   = modvendor.Currency;
                            mod.UnitNo     = modco.UnitNo;
                            mod.Qty        = modco.Qty;
                            mod.Price      = 0;
                            mod.UpdateUser = Util.UserId;
                            list.Add(mod);
                        }
                        else
                        {
                            for (int i = 0; i < DBGrid.SelectedRows.Count; i++)
                            {
                                if (DBGrid.SelectedRows[i].Visible)
                                {
                                    modCustomerOrderList modco = (modCustomerOrderList)DBGrid.SelectedRows[i].DataBoundItem;
                                    modVendorOrderList   mod   = new modVendorOrderList();
                                    mod.Id          = 0;
                                    mod.FormDate    = DateTime.Today;
                                    mod.RequireDate = DateTime.Today;
                                    //mod.VendorOrderNo = modco.CustOrderNo;
                                    mod.Remark      = modco.CustName + ": " + modco.CustOrderNo;
                                    mod.VendorName  = Util.retValue1;
                                    mod.PayMethod   = string.Empty;
                                    mod.PurchaseMan = Util.UserId;
                                    mod.ProductId   = modco.ProductId;
                                    mod.ProductName = modco.ProductName;
                                    if (clsLxms.GetProductSizeFlag(mod.ProductId) == 0)
                                    {
                                        mod.Size = 1;
                                    }
                                    else
                                    {
                                        mod.Size = modco.Size;
                                    }
                                    mod.Currency   = modvendor.Currency;
                                    mod.UnitNo     = modco.UnitNo;
                                    mod.Qty        = modco.Qty;
                                    mod.Price      = 0;
                                    mod.UpdateUser = Util.UserId;
                                    list.Add(mod);
                                }
                            }
                        }
                        VendorOrderImport frmImport = new VendorOrderImport();
                        frmImport.InitViewList(list);
                        frmImport.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #13
0
        private void toolExport_Click(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }

            IList <modExcelRangeData> list = new List <modExcelRangeData>();

            decimal        summny      = 0;
            string         custid      = string.Empty;
            string         custorderno = string.Empty;
            dalProductList dalpdt      = new dalProductList();

            if (DBGrid.SelectedRows.Count == 0)
            {
                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    if (DBGrid.Rows[i].Visible)
                    {
                        modCustomerOrderList modd = (modCustomerOrderList)DBGrid.Rows[i].DataBoundItem;
                        if (string.IsNullOrEmpty(custid))
                        {
                            dalCustomerList dalcust = new dalCustomerList();
                            modCustomerList modcust = dalcust.GetItem(modd.CustId, out Util.emsg);

                            custid      = modd.CustId;
                            custorderno = modd.CustOrderNo;
                            list.Add(new modExcelRangeData(modcust.FullName, "B6", "E6"));
                            list.Add(new modExcelRangeData(modd.CustOrderNo, "I6", "I6"));
                            list.Add(new modExcelRangeData(modd.FormDate.ToString("yyyy年MM月dd日"), "I7", "I7"));
                        }
                        else
                        {
                            if (custid != modd.CustId)
                            {
                                MessageBox.Show("您所选的订单必须属于同一个客户!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            if (custorderno != modd.CustOrderNo)
                            {
                                if (MessageBox.Show("您所选的订单不是同一个订单编号,是否要继续?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.No)
                                {
                                    return;
                                }
                            }
                        }
                        string col = (10 + i).ToString().Trim();
                        list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col));
                        modProductList modpdt = dalpdt.GetItem(modd.ProductId, out Util.emsg);
                        if (modpdt != null)
                        {
                            list.Add(new modExcelRangeData(modpdt.Brand, "C" + col, "C" + col));
                        }
                        list.Add(new modExcelRangeData(modd.Qty.ToString(), "D" + col, "D" + col));
                        list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col));
                        list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "G" + col, "G" + col));
                        list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "H" + col, "H" + col));
                        list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col));

                        summny = modd.Qty * modd.Price;
                    }
                }
                list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(summny)), "A23", "I23"));
                list.Add(new modExcelRangeData(string.Format("{0:C2}", summny), "H22", "H22"));
            }
            else
            {
                for (int i = 0; i < DBGrid.SelectedRows.Count; i++)
                {
                    if (DBGrid.SelectedRows[i].Visible)
                    {
                        modCustomerOrderList modd = (modCustomerOrderList)DBGrid.SelectedRows[i].DataBoundItem;
                        if (string.IsNullOrEmpty(custid))
                        {
                            dalCustomerList dalcust = new dalCustomerList();
                            modCustomerList modcust = dalcust.GetItem(modd.CustId, out Util.emsg);

                            custid      = modd.CustId;
                            custorderno = modd.CustOrderNo;
                            list.Add(new modExcelRangeData(modcust.FullName, "B6", "E6"));
                            list.Add(new modExcelRangeData(modd.CustOrderNo, "I6", "I6"));
                            list.Add(new modExcelRangeData(modd.FormDate.ToString("yyyy年MM月dd日"), "I7", "I7"));
                        }
                        else
                        {
                            if (custid != modd.CustId)
                            {
                                MessageBox.Show("您所选的订单必须属于同一个客户!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            if (custorderno != modd.CustOrderNo)
                            {
                                if (MessageBox.Show("您所选的订单不是同一个订单编号,是否要继续?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.No)
                                {
                                    return;
                                }
                            }
                        }
                        string col = (10 + i).ToString().Trim();
                        list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col));
                        modProductList modpdt = dalpdt.GetItem(modd.ProductId, out Util.emsg);
                        if (modpdt != null)
                        {
                            list.Add(new modExcelRangeData(modpdt.Brand, "C" + col, "C" + col));
                        }
                        list.Add(new modExcelRangeData(modd.Qty.ToString(), "D" + col, "D" + col));
                        list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col));
                        list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "G" + col, "G" + col));
                        list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "H" + col, "H" + col));
                        list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col));

                        summny = modd.Qty * modd.Price;
                    }
                }
                list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(summny)), "A23", "I23"));
                list.Add(new modExcelRangeData(string.Format("{0:C2}", summny), "H22", "H22"));
            }
            clsExport.ExportByTemplate(list, "购销合同", 1, 38, 9, 1);
        }
コード例 #14
0
ファイル: DALCUSTOMERORDERLIST.cs プロジェクト: 100009/hberp
        /// <summary>
        /// get all customerorderlist
        /// <summary>
        /// <param name=incfinished>incfinished</param>
        /// <param name=custid>custid</param>
        /// <param name=custname>custname</param>
        /// <param name=custorderno>custorderno</param>
        /// <param name=formdate>formdate</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all customerorderlist</returns>
        public BindingCollection <modCustomerOrderList> GetIList(bool incfinished, string custlist, string custname, string custorderno, string salesmanlist, string fromdate, string todate, out string emsg)
        {
            try
            {
                BindingCollection <modCustomerOrderList> modellist = new BindingCollection <modCustomerOrderList>();
                //Execute a query to read the categories
                string cusidtwhere = string.Empty;
                if (!string.IsNullOrEmpty(custlist) && custlist.CompareTo("ALL") != 0)
                {
                    cusidtwhere = "and cust_id in ('" + custlist.Replace(",", "','") + "') ";
                }

                string custnamewhere = string.Empty;
                if (!string.IsNullOrEmpty(custname))
                {
                    custnamewhere = "and cust_name like '%" + custname + "%' ";
                }

                string salesmanwhere = string.Empty;
                if (!string.IsNullOrEmpty(salesmanlist) && salesmanlist.CompareTo("ALL") != 0)
                {
                    salesmanwhere = "and sales_man in ('" + salesmanlist.Replace(",", "','") + "') ";
                }

                string formdatewhere = string.Empty;
                if (!string.IsNullOrEmpty(fromdate))
                {
                    formdatewhere = "and form_date >= '" + Convert.ToDateTime(fromdate) + "' ";
                }
                if (!string.IsNullOrEmpty(todate))
                {
                    formdatewhere += "and form_date <= '" + Convert.ToDateTime(todate) + "' ";
                }

                dalSysParameters dalpara = new dalSysParameters();
                modSysParameters modpara = dalpara.GetItem("ORDER_FINISHED_RATIO", out emsg);
                decimal          ratio_f = Convert.ToDecimal(modpara.ParaValue);
                string           sql     = "select id,cust_id,cust_name,cust_order_no,form_date,require_date,pay_method,sales_man,product_id,product_name,specify,size,unit_no,qty,price,remark,currency,update_user,update_time "
                                           + "from customer_order_list where 1=1 " + cusidtwhere + custnamewhere + salesmanwhere + formdatewhere + "order by id desc";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modCustomerOrderList model = new modCustomerOrderList();
                        model.Id          = dalUtility.ConvertToInt(rdr["id"]);
                        model.CustId      = dalUtility.ConvertToString(rdr["cust_id"]);
                        model.CustName    = dalUtility.ConvertToString(rdr["cust_name"]);
                        model.CustOrderNo = dalUtility.ConvertToString(rdr["cust_order_no"]);
                        model.FormDate    = dalUtility.ConvertToDateTime(rdr["form_date"]);
                        model.RequireDate = dalUtility.ConvertToDateTime(rdr["require_date"]);
                        model.PayMethod   = dalUtility.ConvertToString(rdr["pay_method"]);
                        model.SalesMan    = dalUtility.ConvertToString(rdr["sales_man"]);
                        model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                        model.ProductName = dalUtility.ConvertToString(rdr["product_name"]);
                        model.Specify     = dalUtility.ConvertToString(rdr["specify"]);
                        model.Size        = dalUtility.ConvertToDecimal(rdr["size"]);
                        model.UnitNo      = dalUtility.ConvertToString(rdr["unit_no"]);
                        model.Qty         = dalUtility.ConvertToDecimal(rdr["qty"]);
                        model.Price       = dalUtility.ConvertToDecimal(rdr["price"]);
                        model.SumMny      = model.Qty * model.Price;
                        model.ShipQty     = GetShipQty(model.CustId, model.CustOrderNo, model.ProductId);
                        model.Differ      = model.Qty - model.ShipQty;
                        model.Remark      = dalUtility.ConvertToString(rdr["remark"]);
                        model.Currency    = dalUtility.ConvertToString(rdr["currency"]);
                        model.UpdateUser  = dalUtility.ConvertToString(rdr["update_user"]);
                        model.UpdateTime  = dalUtility.ConvertToDateTime(rdr["update_time"]);
                        if (incfinished || model.ShipQty < model.Qty * ratio_f)
                        {
                            modellist.Add(model);
                        }
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }
コード例 #15
0
        public void Import(int id)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                _action     = "NEW";
                FillControl.FillDesignType(cboDesignType, false);
                FillControl.FillReceiveStatus(cboReceiveStatus, false);
                FillControl.FillInvoiceStatus(cboInvoiceStatus, false);
                dalCustomerOrderList dal = new dalCustomerOrderList();
                modCustomerOrderList mod = dal.GetItem(id, out Util.emsg);
                if (mod != null)
                {
                    txtId.Text        = "0";
                    dtpFormDate.Value = DateTime.Today;
                    //cboDesignType.SelectedValue = mod.FormType;
                    txtCustOrderNo.Text = mod.CustOrderNo;
                    txtNo.Text          = _dal.GetNewNo(dtpFormDate.Value, mod.CustId);
                    txtCurrency.Text    = mod.Currency;
                    txtCustName.Tag     = mod.CustId;
                    txtCustName.Text    = mod.CustName;
                    txtPayMethod.Text   = mod.PayMethod;
                    txtSalesMan.Text    = mod.SalesMan;
                    txtUnitNo.Text      = mod.UnitNo;
                    txtQty.Text         = mod.Qty.ToString();
                    txtMny.Text         = (mod.Qty * mod.Price).ToString();
                    txtSalesManMny.Text = "0";
                    txtProductName.Text = mod.ProductName;
                    txtRemark.Text      = mod.Remark;
                    txtInvoiceMny.Text  = "0";
                    dalCustomerList dalcust = new DAL.dalCustomerList();
                    modCustomerList modcust = dalcust.GetItem(mod.CustId, out Util.emsg);
                    if (modcust != null)
                    {
                        //txtCustName.Tag = modcust.CustId;
                        //txtCustName.Text = modcust.CustName;
                        //txtPayMethod.Text = modcust.txtPayMethod;
                        //txtSalesMan.Text = modcust.SalesMan;
                        //txtCurrency.Text = mod.Currency;
                        if (modcust.NeedInvoice == 1)
                        {
                            cboReceiveStatus.SelectedIndex = 0;
                            cboInvoiceStatus.SelectedIndex = 1;
                        }
                        else
                        {
                            cboReceiveStatus.SelectedIndex = 1;
                            cboInvoiceStatus.SelectedIndex = 0;
                        }
                    }

                    status4.Image    = null;
                    toolSave.Visible = true;
                    Util.ChangeStatus(this, false);
                    txtId.ReadOnly   = true;
                    toolSave.Enabled = true;

                    cboReceiveStatus.Enabled = true;
                    cboInvoiceStatus.Enabled = true;
                    cboAccountNo.Enabled     = true;
                    txtInvoiceMny.ReadOnly   = false;
                    txtInvoiceNo.ReadOnly    = false;
                    btnUpdate.Enabled        = true;
                    btnReceiveDate.Enabled   = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #16
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (dtpFormDate.Value < Util.modperiod.StartDate)
                {
                    MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dtpFormDate.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtSize.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSize.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtSize.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSize.Focus();
                    return;
                }
                else if (Convert.ToDecimal(txtSize.Text.Trim()) <= 0)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSize.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtQty.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtQty.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtQty.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtQty.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtPrice.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Price") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPrice.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtPrice.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Price") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPrice.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtCustOrderNo.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Order No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustOrderNo.Focus();
                    return;
                }
                if (txtCustName.Tag == null)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustName.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtCustName.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustName.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtSalesMan.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Sales Man") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSalesMan.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtUnitNo.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Unit No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtUnitNo.Focus();
                    return;
                }
                if (txtProductName.Tag == null)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Product Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtProductName.Focus();
                    return;
                }
                modCustomerOrderList mod = new modCustomerOrderList();
                mod.Id          = Convert.ToInt32(txtId.Text);
                mod.FormDate    = dtpFormDate.Value;
                mod.RequireDate = dtpRequireDate.Value;
                mod.CustOrderNo = txtCustOrderNo.Text.Trim();
                mod.CustId      = txtCustName.Tag.ToString();
                mod.CustName    = txtCustName.Text.Trim();
                mod.PayMethod   = txtPayMethod.Text.Trim();
                mod.SalesMan    = txtSalesMan.Text.Trim();
                mod.ProductId   = txtProductName.Tag.ToString();
                mod.ProductName = txtProductName.Text.Trim();
                if (clsLxms.GetProductSizeFlag(mod.ProductId) == 0)
                {
                    mod.Size = 1;
                }
                else
                {
                    mod.Size = Convert.ToDecimal(txtSize.Text);
                }
                mod.Remark     = txtRemark.Text.Trim();
                mod.Currency   = txtCurrency.Text.Trim();
                mod.UnitNo     = txtUnitNo.Text.Trim();
                mod.Qty        = Convert.ToDecimal(txtQty.Text);
                mod.Price      = Convert.ToDecimal(txtPrice.Text);
                mod.UpdateUser = Util.UserId;
                string detaillist = string.Empty;

                bool ret = false;
                if (_action == "ADD" || _action == "NEW")
                {
                    ret = _dal.Insert(mod, out Util.emsg);
                    if (ret)
                    {
                        if (MessageBox.Show("保存成功,是否继续添加?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            txtProductName.Tag  = null;
                            txtProductName.Text = string.Empty;
                            txtSize.Text        = string.Empty;
                            txtUnitNo.Text      = string.Empty;
                            txtQty.Text         = string.Empty;
                            txtPrice.Text       = string.Empty;
                            txtRemark.Text      = string.Empty;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Dispose();
                        }
                    }
                    else
                    {
                        MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    ret = _dal.Update(mod.Id, mod, out Util.emsg);
                    if (ret)
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }