Пример #1
0
 private void toolImport_Click(object sender, EventArgs e)
 {
     try
     {
         frmViewList      frmsel  = new frmViewList();
         dalQuotationForm dalquot = new dalQuotationForm();
         BindingCollection <modVQuotationDetail> listquot = dalquot.GetVDetail(string.Empty, string.Empty, string.Empty, string.Empty, DateTime.Today.AddDays(-30).ToString("MM-dd-yyyy"), string.Empty, out Util.emsg);
         if (listquot != null)
         {
             frmsel.InitViewList("请选择要导入的客户报价单号:", listquot);
             frmsel.Selection = true;
             if (frmsel.ShowDialog() == DialogResult.OK)
             {
                 modVQuotationDetail mod = dalquot.GetDetailItem(Util.retValue1, Convert.ToInt32(Util.retValue2), out Util.emsg);
                 if (mod != null)
                 {
                     EditCustomerOrderList frm = new EditCustomerOrderList();
                     frm.ImportItem(mod);
                     if (frm.ShowDialog() == DialogResult.OK)
                     {
                         LoadData();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
0
        public void ImportItem(modVQuotationDetail mod)
        {
            _action              = "NEW";
            dtpFormDate.Value    = DateTime.Today;
            dtpRequireDate.Value = DateTime.Today;
            txtId.Text           = "0";
            //txtCustOrderNo.Text = mod.CustOrderNo;
            txtCurrency.Text = mod.Currency;
            txtCustName.Tag  = mod.CustId;
            txtCustName.Text = mod.CustName;
            dalCustomerList dalcust = new dalCustomerList();
            modCustomerList modcust = dalcust.GetItem(mod.CustId, out Util.emsg);

            if (modcust != null)
            {
                txtPayMethod.Text = modcust.PayMethod;
                txtSalesMan.Text  = modcust.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        = "1";
            txtRemark.Text      = mod.Remark;

            status4.Image = null;
        }
Пример #3
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=formid>formid</param>
 /// <param name=seq>seq</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of quotationform</returns>
 public modVQuotationDetail GetDetailItem(string formid, int seq, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select a.form_id,a.form_date,a.no,c.cust_id,c.cust_name,b.seq,b.product_id,b.product_name,b.specify,b.brand,b.size,b.unit_no,b.qty,b.price,b.remark,a.currency "
                                    + "from quotation_form a inner join quotation_detail b on a.form_id=b.form_id inner join customer_list c on a.cust_id=c.cust_id "
                                    + "where a.form_id='{0}' and b.seq={1}", formid, seq);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modVQuotationDetail model = new modVQuotationDetail();
                 model.FormId      = dalUtility.ConvertToString(rdr["form_id"]);
                 model.Seq         = dalUtility.ConvertToInt(rdr["seq"]);
                 model.FormDate    = dalUtility.ConvertToDateTime(rdr["form_date"]);
                 model.No          = dalUtility.ConvertToString(rdr["no"]);
                 model.CustId      = dalUtility.ConvertToString(rdr["cust_id"]);
                 model.CustName    = dalUtility.ConvertToString(rdr["cust_name"]);
                 model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                 model.ProductName = dalUtility.ConvertToString(rdr["product_name"]);
                 model.Specify     = dalUtility.ConvertToString(rdr["specify"]);
                 model.Brand       = dalUtility.ConvertToString(rdr["brand"]);
                 model.UnitNo      = dalUtility.ConvertToString(rdr["unit_no"]);
                 model.Qty         = dalUtility.ConvertToDecimal(rdr["qty"]);
                 model.Price       = dalUtility.ConvertToDecimal(rdr["price"]);
                 model.Mny         = model.Qty * model.Price;
                 model.Remark      = dalUtility.ConvertToString(rdr["remark"]);
                 model.Currency    = dalUtility.ConvertToString(rdr["currency"]);
                 emsg = string.Empty;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Пример #4
0
        /// <summary>
        /// get all quotationdetail
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all quotationdetail</returns>
        public BindingCollection <modVQuotationDetail> GetVDetail(string custlist, string custname, string productidlist, string productname, string fromdate, string todate, out string emsg)
        {
            try
            {
                BindingCollection <modVQuotationDetail> modellist = new BindingCollection <modVQuotationDetail>();
                //Execute a query to read the categories
                string productidwhere = string.Empty;
                if (!string.IsNullOrEmpty(productidlist) && productidlist.CompareTo("ALL") != 0)
                {
                    productidwhere = "and b.product_id in ('" + productidlist.Replace(",", "','") + "') ";
                }

                string productnamewhere = string.Empty;
                if (!string.IsNullOrEmpty(productname))
                {
                    productnamewhere = "and b.product_name like '%" + productname + "%' ";
                }

                string cusidtwhere = string.Empty;
                if (!string.IsNullOrEmpty(custlist) && custlist.CompareTo("ALL") != 0)
                {
                    cusidtwhere = "and a.cust_id in ('" + custlist.Replace(",", "','") + "') ";
                }

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

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

                string sql = "select a.form_id,a.form_date,a.no,c.cust_id,c.cust_name,b.seq,b.product_id,b.product_name,b.specify,b.brand,b.size,b.unit_no,b.qty,b.price,b.remark,a.currency "
                             + "from quotation_form a inner join quotation_detail b on a.form_id=b.form_id inner join customer_list c on a.cust_id=c.cust_id "
                             + "where 1=1 " + cusidtwhere + custnamewhere + productidwhere + productnamewhere + formdatewhere + " order by b.product_id,a.form_date";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modVQuotationDetail model = new modVQuotationDetail();
                        model.FormId      = dalUtility.ConvertToString(rdr["form_id"]);
                        model.Seq         = dalUtility.ConvertToInt(rdr["seq"]);
                        model.FormDate    = dalUtility.ConvertToDateTime(rdr["form_date"]);
                        model.No          = dalUtility.ConvertToString(rdr["no"]);
                        model.CustId      = dalUtility.ConvertToString(rdr["cust_id"]);
                        model.CustName    = dalUtility.ConvertToString(rdr["cust_name"]);
                        model.ProductId   = dalUtility.ConvertToString(rdr["product_id"]);
                        model.ProductName = dalUtility.ConvertToString(rdr["product_name"]);
                        model.Specify     = dalUtility.ConvertToString(rdr["specify"]);
                        model.Brand       = dalUtility.ConvertToString(rdr["brand"]);
                        model.UnitNo      = dalUtility.ConvertToString(rdr["unit_no"]);
                        model.Qty         = dalUtility.ConvertToDecimal(rdr["qty"]);
                        model.Price       = dalUtility.ConvertToDecimal(rdr["price"]);
                        model.Mny         = model.Qty * model.Price;
                        model.Remark      = dalUtility.ConvertToString(rdr["remark"]);
                        model.Currency    = dalUtility.ConvertToString(rdr["currency"]);
                        modellist.Add(model);
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }