Exemplo n.º 1
0
        private void toolExport_Click(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }
            IList <modExcelRangeData> list = new List <modExcelRangeData>();
            modQuotationForm          mod  = (modQuotationForm)DBGrid.CurrentRow.DataBoundItem;
            BindingCollection <modQuotationDetail> listdetail = _dal.GetDetail(mod.FormId, out Util.emsg);
            dalCustomerList dalcust = new dalCustomerList();
            modCustomerList modcust = dalcust.GetItem(mod.CustId, out Util.emsg);

            //list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_NAME"), "B1", "J1"));
            list.Add(new modExcelRangeData("电话/TEL: " + clsLxms.GetParameterValue("COMPANY_TEL") + "                 传真/FAX: " + clsLxms.GetParameterValue("COMPANY_FAX") + "                 联系人/Contact Person: " + mod.ContactPerson, "A4", "I4"));
            //list.Add(new modExcelRangeData("公司地址:" + clsLxms.GetParameterValue("COMPANY_ADDR"), "B3", "J3"));
            list.Add(new modExcelRangeData(modcust.FullName, "B6", "B6"));
            list.Add(new modExcelRangeData("TEL: " + modcust.Linkman + "  " + modcust.Tel, "B7", "B7"));
            list.Add(new modExcelRangeData("单号Invoice No.: " + mod.No, "H6", "H6"));
            list.Add(new modExcelRangeData(mod.FormDate.ToString("yyyy/MM/dd"), "I8", "I8"));

            for (int i = 0; i < listdetail.Count; i++)
            {
                modQuotationDetail modd = listdetail[i];
                string             col  = (10 + i).ToString().Trim();
                list.Add(new modExcelRangeData((i + 1).ToString(), "A" + col, "A" + col));
                list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col));
                list.Add(new modExcelRangeData(modd.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.Mny), "H" + col, "H" + col));
                list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col));
            }
            clsExport.ExportByTemplate(list, "报价单", 1, 20, 10, 1);
        }
Exemplo n.º 2
0
 public void EditItem(string formid)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         _action     = "EDIT";
         modQuotationForm mod = _dal.GetItem(formid, out Util.emsg);
         if (mod != null)
         {
             txtFormId.Text        = formid;
             dtpFormDate.Value     = mod.FormDate;
             txtNo.Text            = mod.No;
             txtCurrency.Text      = mod.Currency;
             txtCustName.Tag       = mod.CustId;
             txtCustName.Text      = mod.CustName;
             txtRemark.Text        = mod.Remark;
             txtContactPerson.Text = mod.ContactPerson;
             txtFormId.ReadOnly    = true;
             txtCustName.ReadOnly  = true;
             DBGrid.Rows.Clear();
             LoadDBGrid();
             BindingCollection <modQuotationDetail> list = _dal.GetDetail(formid, out Util.emsg);
             if (list == null && !string.IsNullOrEmpty(Util.emsg))
             {
                 MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 dalProductList dalpdt = new dalProductList();
                 foreach (modQuotationDetail modd in list)
                 {
                     DataGridViewRow row = new DataGridViewRow();
                     row.CreateCells(DBGrid);
                     row.Cells[0].Value = modd.ProductId;
                     row.Cells[1].Value = modd.ProductName;
                     row.Cells[2].Value = modd.Specify;
                     row.Cells[3].Value = modd.UnitNo;
                     row.Cells[4].Value = modd.Brand;
                     row.Cells[5].Value = modd.Qty.ToString();
                     row.Cells[6].Value = modd.Price.ToString();
                     row.Cells[7].Value = modd.Remark;
                     row.Height         = 40;
                     DBGrid.Rows.Add(row);
                     row.Dispose();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }