Exemplo n.º 1
0
        private void toolExport_Click(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }

            frmSingleSelect frm = new frmSingleSelect();

            frm.InitData("请选择导出单据类别:", "购销合同,采购订单", "购销合同", ComboBoxStyle.DropDownList);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                IList <modExcelRangeData>             list       = new List <modExcelRangeData>();
                modPurchaseList                       mod        = (modPurchaseList)DBGrid.CurrentRow.DataBoundItem;
                BindingCollection <modPurchaseDetail> listdetail = _dal.GetDetail(mod.PurchaseId, out Util.emsg);

                switch (Util.retValue1)
                {
                case "采购订单":
                    dalVendorList dalv = new dalVendorList();
                    modVendorList modv = dalv.GetItem(mod.VendorName, out Util.emsg);
                    list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_NAME"), "A1", "I1"));
                    list.Add(new modExcelRangeData("电话:" + clsLxms.GetParameterValue("COMPANY_TEL") + "      传真:" + clsLxms.GetParameterValue("COMPANY_FAX"), "A2", "I2"));
                    list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_ADDR"), "A3", "I3"));
                    list.Add(new modExcelRangeData(modv.VendorName, "C6", "E6"));
                    list.Add(new modExcelRangeData(modv.Tel, "C7", "E7"));
                    list.Add(new modExcelRangeData(modv.Fax, "C8", "E8"));
                    list.Add(new modExcelRangeData(modv.Linkman, "C9", "E9"));
                    list.Add(new modExcelRangeData(modv.Addr, "C10", "E10"));

                    list.Add(new modExcelRangeData(mod.PurchaseNo, "G6", "I6"));
                    list.Add(new modExcelRangeData(mod.PurchaseDate.ToString("yyyy年MM月dd日"), "G7", "I7"));
                    list.Add(new modExcelRangeData(mod.UpdateUser, "G8", "I8"));
                    list.Add(new modExcelRangeData(mod.txtPayMethod, "G9", "I9"));
                    list.Add(new modExcelRangeData(mod.UpdateUser, "F38", "F38"));
                    for (int i = 0; i < listdetail.Count; i++)
                    {
                        modPurchaseDetail modd = listdetail[i];
                        string            col  = (13 + i).ToString().Trim();
                        list.Add(new modExcelRangeData((i + 1).ToString(), "A" + col, "A" + col));
                        list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "C" + col));
                        list.Add(new modExcelRangeData(modd.Brand, "D" + col, "D" + col));
                        list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col));
                        list.Add(new modExcelRangeData(modd.Qty.ToString(), "F" + col, "F" + 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));
                    }
                    clsExport.ExportByTemplate(list, "采购单", 1, 38, 9, 1);
                    break;

                case "购销合同":
                    list.Add(new modExcelRangeData(mod.VendorName, "B6", "E6"));
                    list.Add(new modExcelRangeData(mod.PurchaseNo, "I6", "I6"));
                    list.Add(new modExcelRangeData(mod.PurchaseDate.ToString("yyyy年MM月dd日"), "I7", "I7"));
                    list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(mod.DetailSum + mod.OtherMny - mod.KillMny)), "A23", "I23"));
                    list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.DetailSum + mod.OtherMny - mod.KillMny), "H22", "H22"));

                    for (int i = 0; i < listdetail.Count; i++)
                    {
                        modPurchaseDetail 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.Qty * modd.Price), "H" + col, "H" + col));
                        list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col));
                    }
                    clsExport.ExportByTemplate(list, "购销合同", 1, 41, 9, 1);
                    break;
                }
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        private void toolImport_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                frmSingleSelect frm       = new frmSingleSelect();
                dalVendorList   dalvendor = new dalVendorList();
                BindingCollection <modVendorList> listvendor = dalvendor.GetIList("1", string.Empty, out Util.emsg);
                if (listvendor != null)
                {
                    frm.InitViewList("请选择供应商", listvendor, "VendorName", "VendorName", ComboBoxStyle.DropDown);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        modVendorList modvendor = dalvendor.GetItem(Util.retValue1, out Util.emsg);
                        frmSelectGrid frmsel    = new frmSelectGrid();

                        dalPurchaseList dalorder = new dalPurchaseList();
                        BindingCollection <modCustomerOrderList> listorder = dalorder.GetImportOrderData(DateTime.Today.AddDays(-30).ToString("MM-dd-yyyy"), string.Empty, out Util.emsg);
                        if (listorder != null)
                        {
                            frmsel.InitViewList("请选择要导入的客户订单号:", listorder);
                            if (frmsel.ShowDialog() == DialogResult.OK)
                            {
                                BindingCollection <modVendorOrderList> list = new BindingCollection <modVendorOrderList>();
                                dalCustomerOrderList dalco = new dalCustomerOrderList();
                                BindingCollection <modCustomerOrderList> listco = dalco.GetIList(frmSelectGrid.selectionlist, out Util.emsg);
                                foreach (modCustomerOrderList modco in listco)
                                {
                                    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);
                                if (frmImport.ShowDialog() == DialogResult.OK)
                                {
                                    LoadData();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }