示例#1
0
        public string CheckHsCode(string hsCode, string title)
        {
            if (hsCode == null || "".Equals(hsCode))
            {
                return(title + ERROR_NULL);
            }
            BHsCode bHsCode = new BHsCode();

            if (bHsCode.Exists(hsCode))
            {
                return("");
            }
            return(title + ERROR_EXIST);
        }
示例#2
0
        //#region   包装费用
        //private void btnDivPackAmount_Click(object sender, EventArgs e)
        //{
        //    if (txtPackAmount.Text != "")
        //    {
        //        if (CConvert.ToDecimal(txtPackAmount.Text) > 0 && hashTable.Count > 0 && total_un_invoice_amount > 0)
        //        {
        //            decimal total = CConvert.ToDecimal(txtPackAmount.Text);
        //            decimal other = 0;
        //            int i = 1;
        //            foreach (DataGridViewRow row in dgvData.Rows)
        //            {
        //                if (i < dgvData.Rows.Count)
        //                {
        //                    if (row.Cells["PO_SLIP_NUMBER"].Value != null && row.Cells["PO_SLIP_NUMBER"].Value.ToString() != "")
        //                    {
        //                        row.Cells["PACKAGE_AMOUNT"].Value = Math.Round((CConvert.ToDecimal(row.Cells["UN_INVOICE_AMOUNT"].Value) / total_un_invoice_amount) * total, 2);
        //                        other += CConvert.ToDecimal(row.Cells["PACKAGE_AMOUNT"].Value);
        //                        i++;
        //                    }
        //                }
        //                else if (i == dgvData.Rows.Count)
        //                {
        //                    if (row.Cells["PO_SLIP_NUMBER"].Value != null && row.Cells["PO_SLIP_NUMBER"].Value.ToString() != "")
        //                    {
        //                        row.Cells["PACKAGE_AMOUNT"].Value = total - other;
        //                    }
        //                }
        //            }
        //        }
        //        else
        //        {
        //            MessageBox.Show("包装费用不能小于0!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        //        }
        //    }
        //    else
        //    {
        //        MessageBox.Show("包装费用不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        //        return;
        //    }
        //}
        //#endregion

        #region dgvData单元格验证
        private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dr           = dgvData.Rows[e.RowIndex];
            string          suppliercode = CConvert.ToString(dr.Cells["SUPPLIER_CODE"].Value);

            if (!string.IsNullOrEmpty(suppliercode))
            {
                if (e.ColumnIndex == dgvData.Columns["AMOUNT"].Index)
                {
                    if (CConvert.ToDecimal(dr.Cells["AMOUNT"].Value) > CConvert.ToDecimal(dr.Cells["AMOUNT_INCLUDED_TAX"].Value))
                    {
                        MessageBox.Show("开票金额不能大于金额!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dr.Cells["AMOUNT"].Value    = "";
                        dr.Cells["AMOUNT"].Selected = true;
                    }

                    if (new BSupplier().GetModel(suppliercode).TYPE == 1)
                    {
                        string productcode = CConvert.ToString(dr.Cells["PRODUCT_CODE"].Value);
                        if (!string.IsNullOrEmpty(productcode))
                        {
                            string   hscode = new BProduct().GetModel(productcode).HS_CODE;
                            decimal  exch   = 0;
                            DateTime date   = CConvert.ToDateTime(txtPurchaseDate.Value.Year + "/" + txtPurchaseDate.Value.Month + "/" + 1);
                            try
                            {
                                exch = new BExchange().GetModel(date, dr.Cells["CURRENCY_CODE"].Value.ToString()).EXCHANGE_RATE;
                            }
                            catch { exch = 1; }
                            if (!string.IsNullOrEmpty(hscode))
                            {
                                decimal tax = new BHsCode().GetModel(hscode).TAX_RATE;
                                dr.Cells["TAX_AMOUNT"].Value = CConvert.ToDecimal(dr.Cells["AMOUNT"].Value) * (tax / 100) * (exch / 100);
                            }
                            else
                            {
                                dr.Cells["TAX_AMOUNT"].Value = 0;
                            }
                        }
                        else
                        {
                            dr.Cells["TAX_AMOUNT"].Value = 0;
                        }
                    }
                }
            }
        }
示例#3
0
 private void txtHsCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtHsCode.Text.Trim()))
     {
         BaseHsCodeTable HsCode  = new BaseHsCodeTable();
         BHsCode         bHsCode = new BHsCode();
         HsCode = bHsCode.GetModel(this.txtHsCode.Text);
         if (HsCode == null || "".Equals(HsCode))
         {
             txtHsCode.Focus();
             txtHsCode.Text = "";
             txtHsName.Text = "";
             MessageBox.Show("海关编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtHsName.Text = HsCode.HS_NAME;
         }
     }
 }