コード例 #1
0
ファイル: FrmReceiptSearch.cs プロジェクト: zhr008/ERP-1
 private void txtSupplierCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtSupplierCode.Text.Trim()))
     {
         BaseSupplierTable SupplierCode = new BaseSupplierTable();
         BSupplier         bSupplier    = new BSupplier();
         SupplierCode = bSupplier.GetModel(txtSupplierCode.Text);
         if (SupplierCode == null)
         {
             txtSupplierCode.Focus();
             txtSupplierCode.Text = "";
             txtSupplierName.Text = "";
             MessageBox.Show("供应商编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtSupplierName.Text = SupplierCode.NAME;
         }
     }
     else
     {
         txtSupplierCode.Text = "";
         txtSupplierName.Text = "";
     }
 }
コード例 #2
0
 private void gvArticles_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     try
     {
         if (gvArticles.FocusedRowHandle >= 0)
         {
             ObjESupplier.dtArticlesMerge = ObjESupplier.dtArticleID.Copy();
             DataRow dr = ObjESupplier.dtArticlesMerge.NewRow();
             dr["ID"] = gvArticles.GetFocusedRowCellValue("WGID");
             ObjESupplier.dtArticlesMerge.Rows.Add(dr);
             if (ObjBSupplier == null)
             {
                 ObjBSupplier = new BSupplier();
             }
             ObjBSupplier.GetSuppliersForProposalMerge(ObjESupplier);
             chkSuppliersList.DataSource    = ObjESupplier.dtSupplierForproposal;
             chkSuppliersList.DisplayMember = "ShortName";
             chkSuppliersList.ValueMember   = "SupplierID";
             DataRowView row = null;
             for (int i = 0; i < ObjESupplier.dtSupplierForproposal.Rows.Count; i++)
             {
                 row = chkSuppliersList.GetItem(i) as DataRowView;
                 if (Convert.ToInt16(row["ItemChecked"]) == 1)
                 {
                     chkSuppliersList.SetItemChecked(i, true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (gvArticles.FocusedRowHandle >= 0)
         {
             if (ObjBSupplier == null)
             {
                 ObjBSupplier = new BSupplier();
             }
             ObjESupplier.dtSupplierToDB = new DataTable();
             ObjESupplier.dtSupplierToDB.Columns.Add("SupplierID");
             DataRowView row = null;
             DataRow     dr  = null;
             foreach (object item in chkSuppliersList.CheckedItems)
             {
                 row = item as DataRowView;
                 dr  = ObjESupplier.dtSupplierToDB.NewRow();
                 dr["SupplierID"] = row["SupplierID"];
                 ObjESupplier.dtSupplierToDB.Rows.Add(dr);
             }
             ObjBSupplier.SupplierProposalMerge(ObjESupplier);
             ObjESupplier.IsActive = true;
             this.Close();
         }
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtFullName.Text.Trim()))
         {
             throw new Exception("Vollständiger Name Cannot be empty");
         }
         if (!dxValidationProvider1.Validate())
         {
             return;
         }
         if (ObjESupplier == null)
         {
             ObjESupplier = new ESupplier();
         }
         ParseSupplierDetails();
         ObjBSupplier = new BSupplier();
         ObjESupplier = ObjBSupplier.SaveSupplierDetails(ObjESupplier);
         BindSupplierData();
         cmbSupplier.EditValue = ObjESupplier.SupplierID;
         if (Utility._IsGermany)
         {
             frmOTTOPro.UpdateStatus("Vorgang abgeschlossen: Speichern der Lieferantendaten ");
         }
         else
         {
             frmOTTOPro.UpdateStatus("Supplier data saved successfully");
         }
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (txtCompany.Text == string.Empty)
                {
                    MessageError("Fill the fields");
                    errorIcon.SetError(txtCompany, "Insert the Company's name");
                }
                else
                {
                    if (this.eNew)
                    {
                        resp = BSupplier.Insert(this.txtCompany.Text, this.cbComercialSector.Text,
                                                this.cbDocumentType.Text, this.txtDocNumber.Text, this.txtAddress.Text, "1234", this.txtEmail.Text, this.txtUrl.Text
                                                );
                    }
                    else
                    {
                        resp = BSupplier.Edit(Convert.ToInt32(this.txtId.Text),
                                              this.txtCompany.Text, this.cbComercialSector.Text,
                                              this.cbDocumentType.Text, this.txtDocNumber.Text.Trim(), this.txtAddress.Text, "1234", this.txtEmail.Text, this.txtUrl.Text);
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.eNew)
                        {
                            this.MessageOk("Register saved");
                        }
                        else
                        {
                            this.MessageOk("Register Edited");
                        }
                    }
                    else
                    {
                        this.MessageError(resp);
                    }

                    this.eNew  = false;
                    this.eEdit = false;
                    this.Enabledbuttons();
                    this.Clean();
                    this.ShowValues();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #6
0
 private void btnSaveContact_Click(object sender, EventArgs e)
 {
     try
     {
         ParseSupplierContactsDetails();
         if (ObjBSupplier == null)
         {
             ObjBSupplier = new BSupplier();
         }
         _ObjEsupplier = ObjBSupplier.SaveSupplierContactDetails(_ObjEsupplier);
     }
     catch (Exception ex) { Utility.ShowError(ex); }
 }
コード例 #7
0
 private void frmSpreadsheetControl_Load(object sender, EventArgs e)
 {
     try
     {
         ESupplier ObjESupplier = new ESupplier();
         BSupplier ObjBSupplier = new BSupplier();
         ObjBSupplier.GetSupplier(ObjESupplier);
         cmbSupplier.DataSource    = ObjESupplier.dtSupplier;
         cmbSupplier.DisplayMember = "FullName";
         cmbSupplier.ValueMember   = "SupplierID";
     }
     catch (Exception ex) { Utility.ShowError(ex); }
 }
コード例 #8
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         if (ObjBSupplier == null)
         {
             ObjBSupplier = new BSupplier();
         }
         if (ObjESupplier == null)
         {
             ObjESupplier = new ESupplier();
         }
         int IValue = 0;
         if (gvSupplier.FocusedRowHandle >= 0 &&
             int.TryParse(Convert.ToString(gvSupplier.GetFocusedRowCellValue("SupplierID")), out IValue))
         {
             ObjESupplier.SupplierID = IValue;
             ObjESupplier            = ObjBSupplier.CheckSupplierArticle(ObjESupplier);
             if (!string.IsNullOrEmpty(ObjESupplier.strArticleExists))
             {
                 var _result = XtraMessageBox.Show("Der Artikel gehört nicht zum ausgewählten Lieferant, wollen Sie ihn dennoch hinzufügen?", "Bestätigen..?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (Convert.ToString(_result).ToLower() == "ok")
                 {
                     ObjBSupplier.SaveArticleFromProposal(ObjESupplier);
                 }
                 else
                 {
                     return;
                 }
             }
             if (!string.IsNullOrEmpty(ObjESupplier.strSupplierExists))
             {
                 var _result = XtraMessageBox.Show("Für diesen Lieferanten existiert bereits ein Preisangebot. Wollen Sie ein weiteres Preisangebot hinzufügen?", "Bestätigen..?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (Convert.ToString(_result).ToLower() != "ok")
                 {
                     return;
                 }
             }
             _IsSave = true;
             this.Close();
         }
         else
         {
             throw new Exception("Bitte wählen Sie den Lieferanten, der hinzugefügt werden soll");
         }
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #9
0
        private void btnSupplier_Click(object sender, EventArgs e)
        {
            FrmMasterSearch frm = new FrmMasterSearch("SUPPLIER", "");

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                if (frm.BaseMasterTable != null)
                {
                    txtSupplierCode.Text = frm.BaseMasterTable.Code;
                    txtSupplierName.Text = frm.BaseMasterTable.Name;
                    BaseSupplierTable supplier = new BSupplier().GetModel(frm.BaseMasterTable.Code);
                    if (supplier.TYPE == CConstant.ERP_FOREIGN_NUMBER)
                    {
                        txtInvoiceNoLocal.Enabled       = false;
                        txtInvoiceAmountLocal.Enabled   = false;
                        txtInvoiceNoLocal.BackColor     = SystemColors.Info;
                        txtInvoiceAmountLocal.BackColor = SystemColors.Info;
                        txtInvoiceNoLocal.Text          = "";
                        txtInvoiceAmountLocal.Text      = "";
                        txtInvoiceNo.Enabled            = true;
                        txtInvoiceAmount.Enabled        = true;
                        txtInvoiceNo.BackColor          = Color.FromArgb(255, 192, 192);
                        txtInvoiceAmount.BackColor      = Color.FromArgb(255, 192, 192);
                        //txtPackAmount.Text = "";
                        //txtPackAmount.Enabled = true;
                        //btnDivPackAmount.Enabled = true;
                        txtInvoiceNo.Focus();
                    }
                    else if (supplier.TYPE == CConstant.ERP_DOMESTIC_NUMBER)
                    {
                        txtInvoiceNo.Enabled            = false;
                        txtInvoiceAmount.Enabled        = false;
                        txtInvoiceNo.BackColor          = SystemColors.Info;
                        txtInvoiceAmount.BackColor      = SystemColors.Info;
                        txtInvoiceNo.Text               = "";
                        txtInvoiceAmount.Text           = "";
                        txtInvoiceNoLocal.Enabled       = true;
                        txtInvoiceAmountLocal.Enabled   = true;
                        txtInvoiceNoLocal.BackColor     = Color.FromArgb(255, 192, 192);
                        txtInvoiceAmountLocal.BackColor = Color.FromArgb(255, 192, 192);
                        //txtPackAmount.Text = "0";
                        //txtPackAmount.Enabled = false;
                        //btnDivPackAmount.Enabled = false;
                        txtInvoiceNoLocal.Focus();
                    }
                }
            }
            frm.Dispose();
        }
コード例 #10
0
 private void frmSupplierList_Load(object sender, EventArgs e)
 {
     try
     {
         if (ObjBSupplier == null)
         {
             ObjBSupplier = new BSupplier();
         }
         BindSupplierData();
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #11
0
 private void gcArticleDelete_ItemClick(object sender, EventArgs e)
 {
     try
     {
         if (ObjBSupplier == null)
         {
             ObjBSupplier = new BSupplier();
         }
         int IVlaue = 0;
         if (int.TryParse(Convert.ToString(gvArticles.GetFocusedRowCellValue("WGWAID")), out IVlaue))
         {
             ObjESupplier.WGWAID = IVlaue;
             ObjESupplier        = ObjBSupplier.DeleteSupplierArticleMap(ObjESupplier);
             BindArticleData(ObjESupplier.SupplierID);
         }
     }
     catch (Exception ex) { Utility.ShowError(ex); }
 }
コード例 #12
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!this.dxValidationProvider1.Validate())
         {
             return;
         }
         if (_ObjEsupplier == null)
         {
             _ObjEsupplier = new ESupplier();
         }
         ParseSupplierDetails();
         ObjBSupplier = new BSupplier();
         ObjBSupplier.SaveArticle(_ObjEsupplier);
         this.Close();
     }
     catch (Exception ex) { Utility.ShowError(ex); }
 }
コード例 #13
0
        public string CheckSupplier(string supplier, string title)
        {
            if (supplier == null || "".Equals(supplier))
            {
                return(title + ERROR_NULL);
            }
            if (_supplierTable[supplier.ToString()] != null)
            {
                return("");
            }
            BSupplier bSupplier = new BSupplier();

            if (bSupplier.Exists(supplier))
            {
                _supplierTable.Add(supplier, supplier);
                return("");
            }
            return(title + ERROR_EXIST);
        }
コード例 #14
0
ファイル: BuyController.cs プロジェクト: 21ki/kuanmai
        public ActionResult SupplierDetail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("URL地址里的供应商编号不能为空")));
            }

            int oId = 0;

            int.TryParse(id, out oId);
            string uid = HttpContext.User.Identity.Name;

            if (oId <= 0)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("URL地址里的供应商编号只能为数字")));
            }

            BSupplier supplier = null;

            try
            {
                UserManager     userMgr         = new UserManager(int.Parse(uid), null);
                BUser           user            = userMgr.CurrentUser;
                SupplierManager supplierManager = new SupplierManager(user, userMgr.Shop, userMgr.CurrentUserPermission);
                supplier = supplierManager.GetSupplierFullInfo(oId);
                if (supplier == null)
                {
                    return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("没有找到对应的供应商信息")));
                }
            }
            catch (KMJXCException kex)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode(kex.Message)));
            }
            catch
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("未知错误")));
            }
            return(View(supplier));
        }
コード例 #15
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtFullName.Text.Trim()))
         {
             throw new Exception("Vollständiger Name Cannot be empty");
         }
         if (!dxValidationProvider1.Validate())
         {
             return;
         }
         ParseSupplierDetails();
         ObjBSupplier = new BSupplier();
         ObjESupplier = ObjBSupplier.SaveSupplierDetails(ObjESupplier);
         _IsContinue  = true;
         this.Close();
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
コード例 #16
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult option;
                option = MessageBox.Show("Do you really want to delete?", "SysBusiness", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (option == DialogResult.OK)
                {
                    string Code;
                    string resp = "";

                    foreach (DataGridViewRow row in dataList.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Code = Convert.ToString(row.Cells[1].Value);
                            resp = BSupplier.Delete(Convert.ToInt32(Code));

                            if (resp.Equals("OK"))
                            {
                                this.MessageOk("Success deleted");
                            }
                            else
                            {
                                this.MessageError(resp);
                            }
                        }
                    }
                    this.ShowValues();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #17
0
ファイル: SupplierReceive.cs プロジェクト: zhr008/ERP-1
        public override string[] doUpdateDB()
        {
            BaseSupplierTable SupplierTable = null;
            BSupplier         bSupplier     = new BSupplier();
            StringBuilder     strError      = new StringBuilder();
            int    successData    = 0;
            int    failureData    = 0;
            string errorFilePath  = "";
            string backupFilePath = "";

            //数据导入处理
            foreach (DataRow dr in _csvDataTable.Rows)
            {
                StringBuilder str = new StringBuilder();
                //编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE"))))
                {
                    str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号"));
                }
                else
                {
                    str.Append("编号不能为空!");
                }
                //名称
                str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称"));
                //简称
                str.Append(CheckLenght(GetValue(dr, "NAME_SHORT"), 50, "简称"));
                //英文名称
                str.Append(CheckLenght(GetValue(dr, "NAME_ENGLISH"), 50, "英文名称"));
                //邮编
                str.Append(CheckLenght(GetValue(dr, "ZIP_CODE"), 8, "邮编"));
                //地址1
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_FIRST"), 100, "地址1"));
                //地址2
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_MIDDLE"), 100, "地址2"));
                //地址3
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_LAST"), 100, "地址3"));
                //电话
                str.Append(CheckLenght(GetValue(dr, "PHONE_NUMBER"), 20, "电话"));
                //传真
                str.Append(CheckLenght(GetValue(dr, "FAX_NUMBER"), 20, "传真"));
                //联系人名称
                str.Append(CheckLenght(GetValue(dr, "CONTACT_NAME"), 50, "联系人名称"));
                //联系人电话
                str.Append(CheckLenght(GetValue(dr, "MOBIL_NUMBER"), 20, "联系人电话"));
                //邮箱
                str.Append(CheckLenght(GetValue(dr, "EMIAL"), 50, "邮箱"));
                //网址
                str.Append(CheckLenght(GetValue(dr, "URL"), 50, "网址"));
                //备注
                str.Append(CheckLenght(GetValue(dr, "MEMO"), 255, "备注"));
                //类型
                if (CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 2 && CConvert.ToString(GetValue(dr, "TYPE", 1)) != "")
                {
                    str.Append("类型只能为1或2!");
                }
                //是否请款公司
                if (CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "CLAIM_FLAG", 1)) != "")
                {
                    str.Append("是否付款公司只能为1或2!");
                }
                else
                {
                    str.Append(CheckInt(GetValue(dr, "CLAIM_FLAG", 1), 2, "是否付款公司"));
                }
                //请款公司编号
                str.Append(CheckLenght(GetValue(dr, "CLAIM_CODE"), 20, "付款供应商编号"));
                //货币
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CURRENCE_CODE"))))
                {
                    str.Append(CheckCurrency(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")), "货币"));
                }
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", 1), 9, "状态"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    SupplierTable                  = new BaseSupplierTable();
                    SupplierTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    SupplierTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    SupplierTable.NAME_SHORT       = CConvert.ToString(GetValue(dr, "NAME_SHORT"));
                    SupplierTable.NAME_ENGLISH     = CConvert.ToString(GetValue(dr, "NAME_ENGLISH"));
                    SupplierTable.ZIP_CODE         = CConvert.ToString(GetValue(dr, "ZIP_CODE"));
                    SupplierTable.ADDRESS_FIRST    = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST"));
                    SupplierTable.ADDRESS_MIDDLE   = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE"));
                    SupplierTable.ADDRESS_LAST     = CConvert.ToString(GetValue(dr, "ADDRESS_LAST"));
                    SupplierTable.PHONE_NUMBER     = CConvert.ToString(GetValue(dr, "PHONE_NUMBER"));
                    SupplierTable.FAX_NUMBER       = CConvert.ToString(GetValue(dr, "FAX_NUMBER"));
                    SupplierTable.CONTACT_NAME     = CConvert.ToString(GetValue(dr, "CONTACT_NAME"));
                    SupplierTable.MOBIL_NUMBER     = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER"));
                    SupplierTable.EMAIL            = CConvert.ToString(GetValue(dr, "EMIAL"));
                    SupplierTable.URL              = CConvert.ToString(GetValue(dr, "URL"));
                    SupplierTable.MEMO             = CConvert.ToString(GetValue(dr, "MEMO"));
                    SupplierTable.TYPE             = CConvert.ToInt32(GetValue(dr, "TYPE", 1));
                    SupplierTable.CLAIM_FLAG       = CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1));
                    SupplierTable.CLAIM_CODE       = CConvert.ToString(GetValue(dr, "CLAIM_CODE"));
                    SupplierTable.CURRENCE_CODE    = CConvert.ToString(GetValue(dr, "CURRENCE_CODE"));
                    SupplierTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", 1));
                    SupplierTable.CREATE_USER      = _userInfo.CODE;
                    SupplierTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bSupplier.Exists(SupplierTable.CODE))
                    {
                        SupplierTable.CREATE_DATE_TIME = DateTime.Now;
                        SupplierTable.LAST_UPDATE_TIME = DateTime.Now;
                        bSupplier.Add(SupplierTable);
                    }
                    else
                    {
                        SupplierTable.LAST_UPDATE_TIME = DateTime.Now;
                        bSupplier.Update(SupplierTable);
                    }
                    successData++;
                }
                catch
                {
                    strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString());
                    failureData++;
                }
            }
            //错误记录处理
            if (strError.Length > 0)
            {
                errorFilePath = WriteFile(strError.ToString());
            }

            //备份处理
            backupFilePath = BackupFile();

            return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath });
        }
コード例 #18
0
        private void txtSupplierCode_Leave(object sender, EventArgs e)
        {
            string SupplierCode = txtSupplierCode.Text.Trim();

            if (SupplierCode != "")
            {
                BaseSupplierTable supplier = new BSupplier().GetModel(SupplierCode);
                if (supplier != null)
                {
                    txtSupplierCode.Text = supplier.CODE;
                    txtSupplierName.Text = supplier.NAME;
                    if (supplier.TYPE == CConstant.ERP_FOREIGN_NUMBER)
                    {
                        txtInvoiceNoLocal.Enabled       = false;
                        txtInvoiceAmountLocal.Enabled   = false;
                        txtInvoiceNoLocal.BackColor     = SystemColors.Info;
                        txtInvoiceAmountLocal.BackColor = SystemColors.Info;
                        txtInvoiceNoLocal.Text          = "";
                        txtInvoiceAmountLocal.Text      = "";
                        txtInvoiceNo.Enabled            = true;
                        txtInvoiceAmount.Enabled        = true;
                        txtInvoiceNo.BackColor          = Color.FromArgb(255, 192, 192);
                        txtInvoiceAmount.BackColor      = Color.FromArgb(255, 192, 192);
                        if (string.IsNullOrEmpty(slipnumber))
                        {
                            //txtPackAmount.Text = "";
                            //txtPackAmount.Enabled = true;
                            //btnDivPackAmount.Enabled = true;
                        }
                    }
                    else if (supplier.TYPE == CConstant.ERP_DOMESTIC_NUMBER)
                    {
                        txtInvoiceNo.Enabled            = false;
                        txtInvoiceAmount.Enabled        = false;
                        txtInvoiceNo.BackColor          = SystemColors.Info;
                        txtInvoiceAmount.BackColor      = SystemColors.Info;
                        txtInvoiceNo.Text               = "";
                        txtInvoiceAmount.Text           = "";
                        txtInvoiceNoLocal.Enabled       = true;
                        txtInvoiceAmountLocal.Enabled   = true;
                        txtInvoiceNoLocal.BackColor     = Color.FromArgb(255, 192, 192);
                        txtInvoiceAmountLocal.BackColor = Color.FromArgb(255, 192, 192);
                        if (string.IsNullOrEmpty(slipnumber))
                        {
                            //txtPackAmount.Text = "0";
                            //txtPackAmount.Enabled = false;
                            //btnDivPackAmount.Enabled = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("供应商不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtSupplierCode.Text = "";
                    txtSupplierName.Text = "";
                    txtSupplierCode.Focus();
                }
            }
            else
            {
                txtSupplierName.Text = "";
            }
        }
コード例 #19
0
        /// <summary>
        /// Get supplier detail information include products
        /// </summary>
        /// <param name="supplier_id">supplier id</param>
        /// <returns>Instance of BSupplier object</returns>
        public BSupplier GetSupplierFullInfo(int supplier_id, bool getProduct = false)
        {
            BSupplier supplier = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                supplier = (from s in db.Supplier
                            join user in db.User on s.User_ID equals user.User_ID into LUser
                            from l_user in LUser.DefaultIfEmpty()
                            join shop in db.Shop on s.Shop_ID equals shop.Shop_ID into LShop
                            from l_shop in LShop.DefaultIfEmpty()
                            join city in db.Common_District on s.City_ID equals city.id into LCity
                            from l_city in LCity.DefaultIfEmpty()
                            join province in db.Common_District on s.Province_ID equals province.id into LProvince
                            from l_province in LProvince.DefaultIfEmpty()
                            where s.Supplier_ID == supplier_id
                            select new BSupplier
                {
                    ID = s.Supplier_ID,
                    Name = s.Name,
                    Address = s.Address,
                    City = l_city != null ? new BArea {
                        ID = l_city.id, Name = l_city.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    ContactPerson = s.Contact_Person,
                    Created = s.Create_Time,
                    Created_By = l_user != null ? new BUser
                    {
                        ID = l_user.User_ID,
                        Name = l_user.Name,
                        Mall_ID = l_user.Mall_ID,
                        Mall_Name = l_user.Mall_Name
                    } : new BUser
                    {
                        ID = 0,
                        Name = "",
                        Mall_ID = "",
                        Mall_Name = ""
                    },
                    Enable = (bool)s.Enabled,
                    Fax = s.Fax,
                    Phone = s.Phone,
                    Province = l_province != null ? new BArea {
                        ID = l_province.id, Name = l_province.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    Remark = s.Remark,
                    Shop = l_shop != null ? new BShop
                    {
                        ID = l_shop.Shop_ID,
                        Title = l_shop.Name
                    } : new BShop
                    {
                        ID = 0,
                        Title = ""
                    }
                }).FirstOrDefault <BSupplier>();

                if (supplier != null && getProduct)
                {
                    List <BProduct> products   = null;
                    var             productIds = from s in db.Product_Supplier
                                                 where s.Supplier_ID == supplier.ID && s.Enabled == true
                                                 select s.Product_ID;

                    products = (from p in db.Product
                                where p.Parent_ID == 0 && productIds.Contains(p.Product_ID)
                                select new BProduct
                    {
                        ID = p.Product_ID,
                        Title = p.Name
                    }).ToList <BProduct>();

                    supplier.Products = products;
                }
            }
            return(supplier);
        }
コード例 #20
0
 private void ShowValues()
 {
     this.dataList.DataSource = BSupplier.ShowValues();
     this.HideCollumns();
     lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found";
 }
コード例 #21
0
 private void SearchDocument()
 {
     this.dataList.DataSource = BSupplier.SearchDocument(this.txtSearch.Text);
     this.HideCollumns();
     lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found";
 }
コード例 #22
0
        private void btnValidateDataNorm_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                try
                {
                    if (dtValidityDate == null)
                    {
                        return;
                    }
                    Worksheet worksheet     = spreadsheetControl1.Document.Worksheets.ActiveWorksheet;
                    Range     range         = worksheet.GetDataRange();
                    Range     SelectedRange = worksheet.SelectedCell;
                    SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);
                    SplashScreenManager.Default.SetWaitFormDescription("Validieren...");
                    int       CCount = 11;
                    int       rCount = range.RowCount;
                    DataTable dt     = new DataTable();
                    for (int j = 0; j < CCount; j++)
                    {
                        if (Convert.ToString(worksheet.Rows[0][j].Value) == "Preis")
                        {
                            dt.Columns.Add(Convert.ToString(worksheet.Rows[0][j].Value), typeof(decimal));
                        }
                        else
                        {
                            dt.Columns.Add(Convert.ToString(worksheet.Rows[0][j].Value), typeof(string));
                        }
                    }

                    DataRow dr = null;
                    for (int i = 1; i < rCount; i++)
                    {
                        dr = dt.NewRow();
                        for (int j = 0; j < CCount; j++)
                        {
                            try
                            {
                                CellValue v = worksheet.Rows[i][j].Value;
                                dr[j] = Convert.ToString(v);
                            }
                            catch (Exception) { }
                        }
                        dt.Rows.Add(dr);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        BSupplier ObjBSupplier = new BSupplier();
                        DataSet   dsResults    = ObjBSupplier.ValidateDataNorm(SupplierID, dtValidityDate, dt);
                        if (dsResults.Tables[0].Rows.Count > 0)
                        {
                            IWorkbook workbook   = spreadsheetControl1.Document;
                            bool      isVLExists = false;
                            bool      isOLExists = false;
                            bool      isILExists = false;
                            foreach (Worksheet ws in workbook.Sheets)
                            {
                                if (ws.Name == "Blatt im Original")
                                {
                                    ws.ConditionalFormattings.Clear();
                                    isOLExists = true;
                                }
                                else if (ws.Name == "Log mit Validierungsangaben")
                                {
                                    ws.ConditionalFormattings.Clear();
                                    isVLExists = true;
                                }
                                else if (ws.Name == "Import des Logs")
                                {
                                    ws.ConditionalFormattings.Clear();
                                    isILExists = true;
                                }
                            }

                            if (isOLExists)
                            {
                                workbook.Worksheets.Add("Sheet1");
                                workbook.Worksheets.Remove(workbook.Worksheets["Blatt im Original"]);
                            }

                            if (isVLExists)
                            {
                                workbook.Worksheets.Remove(workbook.Worksheets["Log mit Validierungsangaben"]);
                            }

                            if (isILExists)
                            {
                                workbook.Worksheets.Remove(workbook.Worksheets["Import des Logs"]);
                            }

                            if (dsResults.Tables.Count > 1)
                            {
                                if (dsResults.Tables[1].Rows.Count > 0)
                                {
                                    btnSaveandConfirm.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                                }
                                else
                                {
                                    btnSaveandConfirm.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                                }
                            }
                            Worksheet sheet = workbook.Worksheets[0];
                            sheet.Name = "Blatt im Original";
                            workbook.BeginUpdate();
                            try
                            {
                                ExternalDataSourceOptions options = new ExternalDataSourceOptions()
                                {
                                    ImportHeaders = true
                                };
                                Table table = sheet.Tables.Add(dsResults.Tables[0], 0, 0, options);
                                table.Columns[0].Name  = "Artikel_Id";
                                table.Columns[1].Name  = "Artikelnummer";
                                table.Columns[2].Name  = "Kurztext1";
                                table.Columns[3].Name  = "Kurztext2";
                                table.Columns[4].Name  = "WG";
                                table.Columns[5].Name  = "WA";
                                table.Columns[6].Name  = "WI";
                                table.Columns[7].Name  = "A";
                                table.Columns[8].Name  = "B";
                                table.Columns[9].Name  = "L";
                                table.Columns[10].Name = "Preis";
                                table.Columns[11].Name = "New/Update";
                                table.Columns[12].Name = "OldPreis";
                                table.Columns[13].Name = "Validity Date";
                                table.Columns[14].Name = "Comments";
                                sheet.DataValidations.Add(sheet["E:K"], DataValidationType.Custom, "=AND(ISNUMBER(E1))");
                                sheet.Range["N:N"].NumberFormat = "mmm/yyyy";
                            }
                            finally
                            {
                                workbook.EndUpdate();
                            }

                            if (dsResults.Tables[1].Rows.Count > 0)
                            {
                                workbook.Worksheets.Add("Log mit Validierungsangaben");
                                Worksheet Vsheet = workbook.Worksheets["Log mit Validierungsangaben"];
                                workbook.BeginUpdate();
                                try
                                {
                                    ExternalDataSourceOptions options = new ExternalDataSourceOptions()
                                    {
                                        ImportHeaders = true
                                    };
                                    Table table = Vsheet.Tables.Add(dsResults.Tables[1], 0, 0, options);
                                    table.Columns[0].Name = "Art_Id";
                                    table.Columns[1].Name = "Comments";
                                }
                                finally
                                {
                                    workbook.EndUpdate();
                                }
                                sheet.Columns.AutoFit(0, 14);
                                workbook.Worksheets.ActiveWorksheet = workbook.Worksheets["Blatt im Original"];
                                Range LogRange = Vsheet.GetDataRange();
                                ApplyNotExistsArticleFormatingforValidationLog(sheet, LogRange, Vsheet);
                                string stRange = SelectedRange.GetReferenceA1();
                                spreadsheetControl1.SelectedCell = sheet.Cells[stRange];
                                SplashScreenManager.CloseForm(false);
                                XtraMessageBox.Show("Die Angaben wurden validiert. Bitte prüfen Sie die Hinweise zur Validierung.");
                            }
                            else
                            {
                                string stRange = SelectedRange.GetReferenceA1();
                                spreadsheetControl1.SelectedCell = sheet.Cells[stRange];
                                sheet.Columns.AutoFit(0, 14);
                                SplashScreenManager.CloseForm(false);
                                XtraMessageBox.Show("Die Angaben wurden validiert. Sämtliche Angaben sind korrekt und vollständig.");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SplashScreenManager.CloseForm(false);
                    XtraMessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #23
0
        private void btnSaveandConfirm_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (SupplierID == null)
                {
                    return;
                }
                if (dtValidityDate == null)
                {
                    return;
                }
                Worksheet worksheet = spreadsheetControl1.Document.Worksheets.ActiveWorksheet;
                Range     range     = worksheet.GetDataRange();
                int       CCount    = 11;
                int       rCount    = range.RowCount;
                SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);
                SplashScreenManager.Default.SetWaitFormDescription("Importieren...");
                DataTable dt = new DataTable();
                for (int j = 0; j < CCount; j++)
                {
                    if (Convert.ToString(worksheet.Rows[0][j].Value) == "Preis")
                    {
                        dt.Columns.Add(Convert.ToString(worksheet.Rows[0][j].Value), typeof(decimal));
                    }
                    else
                    {
                        dt.Columns.Add(Convert.ToString(worksheet.Rows[0][j].Value), typeof(string));
                    }
                }

                DataRow dr = null;
                for (int i = 1; i < rCount; i++)
                {
                    dr = dt.NewRow();
                    for (int j = 0; j < CCount; j++)
                    {
                        try
                        {
                            CellValue v = worksheet.Rows[i][j].Value;
                            dr[j] = Convert.ToString(v);
                        }
                        catch (Exception) {}
                    }
                    dt.Rows.Add(dr);
                }
                if (dt.Rows.Count > 0)
                {
                    BSupplier ObjBSupplier = new BSupplier();
                    DataTable dtResults    = ObjBSupplier.ImportDataNorm(SupplierID, dtValidityDate, dt);
                    if (dtResults.Rows.Count > 0)
                    {
                        IWorkbook workbook   = spreadsheetControl1.Document;
                        bool      isILExists = false;
                        bool      isVLExists = false;
                        foreach (Worksheet ws in workbook.Sheets)
                        {
                            if (ws.Name == "Blatt im Original")
                            {
                                ws.ConditionalFormattings.Clear();
                            }
                            else if (ws.Name == "Import des Logs")
                            {
                                ws.ConditionalFormattings.Clear();
                                isILExists = true;
                            }
                            else if (ws.Name == "Log mit Validierungsangaben")
                            {
                                ws.ConditionalFormattings.Clear();
                                isVLExists = true;
                            }
                        }

                        if (isILExists)
                        {
                            workbook.Worksheets.Remove(workbook.Worksheets["Import des Logs"]);
                        }

                        if (isVLExists)
                        {
                            workbook.Worksheets.Remove(workbook.Worksheets["Log mit Validierungsangaben"]);
                        }

                        workbook.Worksheets.Add("Import des Logs");
                        Worksheet sheet = workbook.Worksheets["Import des Logs"];
                        workbook.BeginUpdate();
                        try
                        {
                            ExternalDataSourceOptions options = new ExternalDataSourceOptions()
                            {
                                ImportHeaders = true
                            };
                            Table table = sheet.Tables.Add(dtResults, 0, 0, options);
                            table.Columns[0].Name = "Art_ID";
                            table.Columns[1].Name = "WG";
                            table.Columns[2].Name = "WA";
                            table.Columns[3].Name = "WI";
                            table.Columns[4].Name = "A";
                            table.Columns[5].Name = "B";
                            table.Columns[6].Name = "L";
                            table.Columns[7].Name = "Error";
                        }
                        finally
                        {
                            workbook.EndUpdate();
                        }

                        Range LogRange = sheet.GetUsedRange();
                        ApplyNotExistsArticleFormatingforImportLog(worksheet, LogRange, sheet);
                        workbook.Worksheets.ActiveWorksheet = workbook.Worksheets["Blatt im Original"];
                    }
                }
                SplashScreenManager.CloseForm(false);
                XtraMessageBox.Show("Die Daten wurden erfolgreiche importiert und gespeichert.");
            }
            catch (Exception ex)
            {
                SplashScreenManager.CloseForm(false);
                XtraMessageBox.Show(ex.Message);
            }
        }
コード例 #24
0
        private void btnPurcahse_Click(object sender, EventArgs e)
        {
            if (dgvData.SelectedRows.Count > 0)
            {
                Hashtable       ht  = null;
                DataTable       dt  = null;
                DataGridViewRow row = dgvData.SelectedRows[0];

                BaseCompanyTable      company   = new BCompany().GetModel(_userInfo.COMPANY_CODE);
                BllPurchaseOrderTable purchase  = bPurchaseOrder.GetModel(CConvert.ToString(row.Cells["SLIP_NUMBER"].Value));
                BllOrderHeaderTable   order     = new BOrderHeader().GetModel(purchase.ORDER_SLIP_NUMBER);
                BaseWarehouseTable    warehouse = new BWarehouse().GetModel(purchase.RECEIPT_WAREHOUSE_CODE);

                if (company == null)
                {
                    company = new BaseCompanyTable();
                }

                if (warehouse == null)
                {
                    warehouse = new BaseWarehouseTable();
                }

                if (purchase == null)
                {
                    purchase = new BllPurchaseOrderTable();
                }
                BaseSupplierTable supplier = new BSupplier().GetModel(purchase.SUPPLIER_CODE);
                if (supplier.TYPE == 2)
                {
                    #region 国内
                    ht = new Hashtable();
                    ht.Add("&COMPANY_NAME", company.NAME);
                    ht.Add("&ADDRESS", company.ADDRESS_FIRST + company.ADDRESS_MIDDLE + company.ADDRESS_LAST);
                    if (string.IsNullOrEmpty(company.PHONE_NUMBER.ToString()))
                    {
                        ht.Add("&PHONE", "TEL                 " + "FAX" + company.FAX_NUMBER);
                    }
                    else
                    {
                        ht.Add("&PHONE", "TEL" + company.PHONE_NUMBER.ToString() + "FAX" + company.FAX_NUMBER);
                    }
                    ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER);
                    ht.Add("&SLIP_DATE", purchase.SLIP_DATE.ToString("yyyy年MM月dd日"));
                    ht.Add("&SUPPLIER", "厂商名称:" + supplier.NAME);
                    //
                    ht.Add("&NAME", company.NAME);
                    ht.Add("&DUE_DATE", "1.交货日期:" + CConvert.ToDateTime(purchase.DUE_DATE).ToShortDateString());
                    ht.Add("&PACKING_METHOD", "2.包装方式:" + purchase.PACKING_METHOD);
                    ht.Add("&WAREHOUSE_NAME", "3.交货地址:" + warehouse.ADDRESS_FIRST + warehouse.ADDRESS_MIDDLE + warehouse.ADDRESS_LAST);
                    ht.Add("&PAYMENT_CONDITION", "4.支付方式:" + purchase.PAYMENT_CONDITION);

                    dt = new DataTable();
                    dt.Columns.Add("NO");
                    dt.Columns.Add("MODEL_NUMBER");
                    dt.Columns.Add("PRODUCT_NAME");
                    dt.Columns.Add("SPEC");
                    dt.Columns.Add("QUANTITY");
                    dt.Columns.Add("PRICE");
                    dt.Columns.Add("AMOUNT_WITHOUT_TAX");
                    //dt.Columns.Add("AMOUNT_INCLUDED_TAX");
                    dt.Columns.Add("DUE_DATE");

                    decimal amount    = 0;
                    decimal taxAmount = 0;
                    DataRow rows      = null;
                    foreach (BllPurchaseOrderLineTable OLModel in purchase.Items)
                    {
                        rows       = dt.NewRow();
                        rows["NO"] = OLModel.LINE_NUMBER;

                        if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999")
                        {
                            rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME;
                            rows["SPEC"]         = OLModel.PRODUCT_SPEC;
                            rows["MODEL_NUMBER"] = "";
                        }
                        else
                        {
                            BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE);
                            if (product != null)
                            {
                                rows["PRODUCT_NAME"] = product.NAME;
                                rows["SPEC"]         = product.SPEC;
                                rows["MODEL_NUMBER"] = product.MODEL_NUMBER;
                            }
                        }
                        rows["QUANTITY"]           = OLModel.QUANTITY;
                        rows["PRICE"]              = OLModel.PRICE;
                        rows["AMOUNT_WITHOUT_TAX"] = Convert.ToDouble(CConvert.ToDecimal(rows["QUANTITY"]) * CConvert.ToDecimal(rows["PRICE"])).ToString("0.00");
                        //rows["AMOUNT_INCLUDED_TAX"] = OLModel.AMOUNT_INCLUDED_TAX;
                        rows["DUE_DATE"] = CConvert.ToDateTime(purchase.DUE_DATE).ToString("yyyy/MM/dd");
                        amount          += OLModel.AMOUNT_WITHOUT_TAX;
                        taxAmount       += OLModel.TAX_AMOUNT;
                        dt.Rows.Add(rows);
                    }

                    ht.Add("&AMOUNT", amount);
                    ht.Add("&TAX_AMOUNT", taxAmount);
                    ht.Add("&TOTAL_AMOUNT", amount + taxAmount);

                    SaveFileDialog sf = new SaveFileDialog();
                    sf.FileName = "LZ_PURCHASE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    sf.Filter   = "(文件)|*.xls;*.xlsx";

                    if (sf.ShowDialog(this) == DialogResult.OK)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            int ret = CommonExport.ExportPurchase(@"rpt\purchase.xls", sf.FileName, dt, ht);
                            if (CConstant.EXPORT_FAILURE.Equals(ret))
                            {
                                MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else if (CConstant.EXPORT_SUCCESS.Equals(ret))
                            {
                                MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (CConstant.EXPORT_RUNNING.Equals(ret))
                            {
                                MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret))
                            {
                                MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    #endregion
                }
                else
                {
                    decimal AMOUNT_WITHOUT_TAX = 0;
                    decimal ORDER_AMOUNT       = 0;
                    #region 国外
                    ht = new Hashtable();
                    ht.Add("&SUPPLIER_NAME", supplier.NAME);
                    ht.Add("&CONTACT_NAME", supplier.CONTACT_NAME);
                    ht.Add("&PHONE", supplier.PHONE_NUMBER);
                    ht.Add("&FAX", supplier.FAX_NUMBER);
                    // ht.Add("&ORDER_NUMBER", purchase.ORDER_SLIP_NUMBER);
                    ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER);
                    ht.Add("&SUPPLIER_ORDER_CODE", purchase.SUPPLIER_ORDER_NUMBER);
                    ht.Add("&PURCHASE_QUOTATION_NUMBER", purchase.PURCHASE_QUOTATION_NUMBER);
                    if (order != null)
                    {
                        ht.Add("&CUSTOMER_PO_NUMBER", order.CUSTOMER_PO_NUMBER);
                        string customerCode = "";
                        //if (!string.IsNullOrEmpty(order.CUSTOMER_NAME))
                        //{
                        //    customerCode = order.CUSTOMER_CODE;
                        //    ht.Add("&CUSTOMER_NAME", order.CUSTOMER_NAME);
                        //}
                        //else
                        //{
                        customerCode = order.ENDER_CUSTOMER_CODE;
                        ht.Add("&CUSTOMER_NAME", order.ENDER_CUSTOMER_NAME);
                        //}

                        ht.Add("&DELIVERY_DATE", order.DUE_DATE);
                        ht.Add("&SERIAL_NUMBER", order.SERIAL_NUMBER);
                        ht.Add("&AIRCRAFT", order.SERIAL_TYPE);
                        BaseCustomerTable customer = new BCustomer().GetModel(customerCode);
                        ht.Add("&CUSTOMER_CONTACT_NAME", customer.CONTACT_NAME);
                        ht.Add("&CUSTOMER_PHONE", customer.PHONE_NUMBER);

                        //ht.Add("&ORDER_AMOUNT", order.AMOUNT_INCLUDED_TAX);
                    }
                    else
                    {
                        ht.Add("&CUSTOMER_PO_NUMBER", "");
                        ht.Add("&DELIVERY_DATE", "");
                        ht.Add("&SERIAL_NUMBER", "");
                        //ht.Add("&ORDER_AMOUNT", "");
                        ht.Add("&AIRCRAFT", "");
                        ht.Add("&CUSTOMER_NAME", company.NAME_SHORT);
                        ht.Add("&CUSTOMER_CONTACT_NAME", "");
                        ht.Add("&CUSTOMER_PHONE", company.PHONE_NUMBER);
                    }

                    ht.Add("&MEMO", purchase.MEMO);
                    ht.Add("&TOTAL_AMOUNT", purchase.TOTAL_AMOUNT);
                    ht.Add("&PAYMENT", purchase.PAYMENT_CONDITION);
                    ht.Add("&SLIP_DATE", purchase.SLIP_DATE);
                    ht.Add("&DUE_DATE", purchase.DUE_DATE);

                    dt = new DataTable();
                    dt.Columns.Add("NO");
                    dt.Columns.Add("PRODUCT_CODE");
                    dt.Columns.Add("X_1", Type.GetType("System.String"));
                    dt.Columns.Add("PRODUCT_NAME");
                    dt.Columns.Add("X_2", Type.GetType("System.String"));
                    dt.Columns.Add("MODEL_NUMBER");
                    dt.Columns.Add("X_3", Type.GetType("System.String"));
                    dt.Columns.Add("QUANTITY");
                    dt.Columns.Add("PRICE");
                    dt.Columns.Add("AMOUNT_WITHOUT_TAX");

                    DataRow rows = null;
                    foreach (BllPurchaseOrderLineTable OLModel in purchase.Items)
                    {
                        AMOUNT_WITHOUT_TAX += OLModel.AMOUNT_INCLUDED_TAX;
                        if (order != null)
                        {
                            foreach (BllOrderLineTable line in order.Items)
                            {
                                if (line.PRODUCT_CODE == OLModel.PRODUCT_CODE)
                                {
                                    ORDER_AMOUNT += CConvert.ToDecimal(line.AMOUNT);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            ORDER_AMOUNT += 0;
                        }

                        rows                 = dt.NewRow();
                        rows["NO"]           = OLModel.LINE_NUMBER;
                        rows["PRODUCT_CODE"] = OLModel.PRODUCT_CODE;
                        if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999")
                        {
                            rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME;
                            rows["MODEL_NUMBER"] = OLModel.PRODUCT_SPEC;
                        }
                        else
                        {
                            BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE);
                            if (product != null)
                            {
                                if (!string.IsNullOrEmpty(product.NAME_JP))
                                {
                                    rows["PRODUCT_NAME"] = product.NAME_JP;
                                }
                                else
                                {
                                    rows["PRODUCT_NAME"] = product.NAME;
                                }
                                rows["MODEL_NUMBER"] = product.SPEC + " " + product.MODEL_NUMBER;
                            }
                        }
                        rows["QUANTITY"]           = OLModel.QUANTITY;
                        rows["PRICE"]              = OLModel.PRICE;
                        rows["AMOUNT_WITHOUT_TAX"] = OLModel.AMOUNT_INCLUDED_TAX;
                        dt.Rows.Add(rows);
                    }
                    ht.Add("&AMOUNT_WITHOUT_TAX", AMOUNT_WITHOUT_TAX);
                    ht.Add("&ORDER_AMOUNT", ORDER_AMOUNT);

                    SaveFileDialog sf = new SaveFileDialog();
                    sf.FileName = "LZ_PURCHASE_OVERSEAS_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    sf.Filter   = "(文件)|*.xls;*.xlsx";

                    if (sf.ShowDialog(this) == DialogResult.OK)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            int ret = CommonExport.ExportPurchaseOverseas(@"rpt\purchase_overseas.xls", sf.FileName, dt, ht);
                            if (CConstant.EXPORT_FAILURE.Equals(ret))
                            {
                                MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else if (CConstant.EXPORT_SUCCESS.Equals(ret))
                            {
                                MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (CConstant.EXPORT_RUNNING.Equals(ret))
                            {
                                MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret))
                            {
                                MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    #endregion
                }
            }
            else
            {
                MessageBox.Show("请选择一行!");
            }
        }