Example #1
0
 private void LoadData()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         DBGrid.toolCancelFrozen_Click(null, null);
         BindingCollection <modVendorOrderList> list = _dal.GetIList(chkIncludeFinished.Checked, cboVendor.SelectedValue.ToString(), string.Empty, string.Empty, dtpFrom.Text, dtpTo.Text, out Util.emsg);
         DBGrid.DataSource = list;
         if (list == null && !string.IsNullOrEmpty(Util.emsg))
         {
             MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             DBGrid.ReadOnly = false;
             for (int i = 0; i < DBGrid.ColumnCount; i++)
             {
                 DBGrid.Columns[i].ReadOnly = true;
             }
             ShowColor();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Example #2
0
        private void toolImport_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                frmSelectGrid   frmsel = new frmSelectGrid();
                frmSingleSelect frms   = new frmSingleSelect();
                frms.InitData("请选择导入方式:", "采购订单,客户订单,EXCEL", "采购订单", ComboBoxStyle.DropDownList);
                if (frms.ShowDialog() == DialogResult.OK)
                {
                    switch (Util.retValue1)
                    {
                    case "客户订单":
                        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)
                            {
                                EditPurchaseList frm = new EditPurchaseList();
                                frm.ImportOrder(frmSelectGrid.selectionlist);
                                if (frm.ShowDialog() == DialogResult.OK)
                                {
                                    LoadData();
                                }
                            }
                        }
                        break;

                    case "采购订单":
                        dalVendorOrderList dalpo = new dalVendorOrderList();
                        BindingCollection <modVendorOrderList> listpo = dalpo.GetIList(false, string.Empty, string.Empty, string.Empty, DateTime.Today.AddDays(-30).ToString("MM-dd-yyyy"), string.Empty, out Util.emsg);
                        if (listpo != null)
                        {
                            frmsel.InitViewList("请选择要导入的采购订单号:", listpo);
                            if (frmsel.ShowDialog() == DialogResult.OK)
                            {
                                EditPurchaseList frm = new EditPurchaseList();
                                frm.ImportPO(frmSelectGrid.selectionlist);
                                if (frm.ShowDialog() == DialogResult.OK)
                                {
                                    LoadData();
                                }
                            }
                        }
                        break;

                    case "EXCEL":
                        OpenFileDialog ofd       = new OpenFileDialog();
                        string         inifolder = clsLxms.GetParameterValue("PURCHASE_IMPORT_PATH");
                        if (Directory.Exists(inifolder))
                        {
                            ofd.InitialDirectory = clsLxms.GetParameterValue("PURCHASE_IMPORT_PATH");
                        }
                        else
                        {
                            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        }
                        ofd.Multiselect      = true;      //允许同时选择多个文件
                        ofd.Filter           = "Excel文件|*.xls;*.xlsx";
                        ofd.RestoreDirectory = true;
                        ofd.FilterIndex      = 1;
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            string[]         files = ofd.FileNames;
                            EditPurchaseList frm   = new EditPurchaseList();
                            frm.Import(files);
                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                LoadData();
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }