Exemplo n.º 1
0
        /// <summary>
        /// Update a ProformaInvoice.
        /// </summary>
        public void Update(Model.ProformaInvoice proformaInvoice)
        {
            //
            // todo: add other logic here.
            //

            Validate(proformaInvoice);

            try
            {
                BL.V.BeginTransaction();

                proformaInvoice.UpdateTime = DateTime.Now;
                accessor.Update(proformaInvoice);

                detailAccessor.DeleteByHeader(proformaInvoice.PO);
                foreach (var item in proformaInvoice.Details)
                {
                    item.ProformaInvoiceId = proformaInvoice.PO;

                    detailAccessor.Insert(item);
                }

                BL.V.CommitTransaction();
            }
            catch (Exception ex)
            {
                BL.V.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Insert a ProformaInvoice.
        /// </summary>
        public void Insert(Model.ProformaInvoice proformaInvoice)
        {
            //
            // todo:add other logic here
            //
            Validate(proformaInvoice);
            if (ExistsPrimary(proformaInvoice.PO))
            {
                throw new Helper.MessageValueException(string.Format("已存在相同的PO:{0}", proformaInvoice.PO));
            }

            try
            {
                BL.V.BeginTransaction();

                proformaInvoice.InsertTime = DateTime.Now;
                proformaInvoice.UpdateTime = DateTime.Now;
                accessor.Insert(proformaInvoice);

                foreach (var item in proformaInvoice.Details)
                {
                    item.ProformaInvoiceId = proformaInvoice.PO;

                    detailAccessor.Insert(item);
                }

                BL.V.CommitTransaction();
            }
            catch (Exception ex)
            {
                BL.V.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 3
0
        protected override void AddNew()
        {
            this.proformaInvoice        = new Book.Model.ProformaInvoice();
            proformaInvoice.InvoiceDate = DateTime.Now;


            this.action = "insert";
        }
Exemplo n.º 4
0
 protected override void MoveLast()
 {
     if (this.LastFlag == 1)
     {
         this.LastFlag = 0;
         return;
     }
     this.proformaInvoice = this.proformaInvoiceManager.GetLast();
 }
Exemplo n.º 5
0
 protected override void MoveNext()
 {
     Model.ProformaInvoice model = this.proformaInvoiceManager.GetNext(this.proformaInvoice);
     if (model == null)
     {
         throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
     }
     this.proformaInvoice = model;
 }
Exemplo n.º 6
0
        public Model.ProformaInvoice GetDetail(string id)
        {
            Model.ProformaInvoice model = this.Get(id);
            if (model != null)
            {
                model.Details = detailAccessor.SelectByHeader(id);
            }

            return(model);
        }
Exemplo n.º 7
0
        protected override Form GetViewForm()
        {
            Model.ProformaInvoice invoice = this.SelectedItem as Model.ProformaInvoice;
            if (invoice != null)
            {
                return(new EditFormProformaInvoice(invoice.PO));
            }

            return(null);
        }
Exemplo n.º 8
0
        public ROProformaInvoice(Model.ProformaInvoice invoice)
        {
            InitializeComponent();

            this.DataSource = invoice.Details;

            //lbl_CompanyName.Text = BL.Settings.CompanyChineseName;
            this.lbl_PO.Text = invoice.PO;
            //this.lbl_InvoiceDate.Text = invoice.InvoiceDate.Value.ToString("yyyy-MM-dd");
            this.lbl_InvoiceDate.Text = invoice.InvoiceDate.Value.ToString("MMM-dd-yyyy", CultureInfo.CreateSpecificCulture("en-GB"));

            this.lbl_CustomerName.Text    = invoice.Customer.CustomerFullName;
            this.lbl_CustomerAddress.Text = invoice.Customer.CustomerAddress;
            this.lbl_CustomerTel.Text     = invoice.Customer.CustomerPhone;
            this.lbl_PaymentTerm.Text     = invoice.Customer.PayCondition;

            this.lbl_Attn.Text            = invoice.Attn;
            this.lbl_CustomerPONo.Text    = invoice.CustomerPONo;
            this.lbl_SalesRep.Text        = invoice.SalesRep;
            this.lbl_TotalEnglish.Text    = invoice.TotalEnglish;
            this.lbl_GoodsReadyDate.Text  = invoice.GOODSREADYDATE;
            this.lbl_CountryOfOrigin.Text = invoice.COUNTRYOFORIGIN;

            if (!string.IsNullOrEmpty(invoice.BankId))
            {
                Model.Bank bank = new BL.BankManager().Get(invoice.BankId);
                if (bank != null)
                {
                    this.lbl_BankName.Text    = bank.BankName;
                    this.lbl_BankAddress.Text = bank.BankAddress;
                    this.lbl_BankTel.Text     = bank.BankPhone;
                    this.lbl_BankFax.Text     = bank.Fax;
                    this.lbl_SWIFTCode.Text   = bank.SWIFTCode;
                    this.lbl_AccountNo.Text   = bank.Id;
                }
            }
            this.lbl_CustomerSign.Text = invoice.Customer.CustomerFullName;

            string currencySign = invoice.Currency + Model.ExchangeRate.GetCurrencySignByENName(invoice.Currency);

            currencySign = (string.IsNullOrEmpty(currencySign) ? "USD$" : currencySign) + " ";

            if (invoice.Details != null && invoice.Details.Count > 0)
            {
                this.TC_TotalQty.Text    = invoice.Details.Sum(P => P.Quantity).Value.ToString("N0");
                this.TC_TotalAmount.Text = currencySign + invoice.Details.Sum(D => D.Amount).Value.ToString("N3");
            }

            TC_ItemCode.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id);
            TC_Desc.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
            TC_Qty.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Quantity, "{0:N0}");
            TC_UnitPrice.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_UnitPrice, currencySign + "{0:N3}");
            TC_Amount.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Amount, currencySign + "{0:N3}");
        }
Exemplo n.º 9
0
        public ROProformaInvoice(Model.ProformaInvoice invoice)
        {
            InitializeComponent();

            this.DataSource = invoice.Details;

            this.lbl_PO.Text = invoice.PO;
            //this.lbl_InvoiceDate.Text = invoice.InvoiceDate.Value.ToString("yyyy-MM-dd");
            this.lbl_InvoiceDate.Text     = invoice.InvoiceDate.Value.ToString("MMM-dd-yyyy", CultureInfo.CreateSpecificCulture("en-GB"));
            this.lbl_CustomerName.Text    = invoice.Customer.CustomerFullName;
            this.lbl_CustomerAddress.Text = invoice.Customer.CustomerAddress;
            this.lbl_DeliveryTO.Text      = invoice.DeliveryTo;
            this.lbl_Tel.Text             = invoice.Customer.CustomerPhone;
            this.lbl_Attn.Text            = invoice.Attn;
            this.lbl_Term.Text            = invoice.Customer.TradingCondition;
            this.lbl_PINO.Text            = invoice.PO;
            this.lbl_Currency.Text        = invoice.Currency;

            this.lbl_Remark.Text       = invoice.Remark;
            this.lbl_DeliveryDate.Text = invoice.DeliveryDate;
            this.lbl_PaymentTerm.Text  = invoice.Customer.PayCondition;
            if (!string.IsNullOrEmpty(invoice.BankId))
            {
                Model.Bank bank = new BL.BankManager().Get(invoice.BankId);
                if (bank != null)
                {
                    this.lbl_AccountName.Text = bank.Description;
                    this.lbl_AccountNo.Text   = bank.Id;
                    this.lbl_BankName.Text    = bank.BankName;
                    this.lbl_BankAddress.Text = bank.BankAddress;
                    this.lbl_SWIFTCode.Text   = bank.SWIFTCode;
                }
            }
            this.lbl_ShippingMark.Text = invoice.ShippimgMark;
            this.lbl_CustomerSign.Text = invoice.Customer.CustomerFullName;

            string currencySign = this.GetCurrencyCode(invoice.Currency) + " ";

            if (invoice.Details != null && invoice.Details.Count > 0)
            {
                this.TC_TotalQty.Text    = invoice.Details.Sum(P => P.Quantity).Value.ToString("N0");
                this.TC_TotalUnit.Text   = invoice.Details[0].Unit;
                this.TC_TotalAmount.Text = currencySign + invoice.Details.Sum(D => D.Amount).Value.ToString("N2");
            }

            TC_No.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Number);
            TC_ItemCode.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_CustomerProductName);
            TC_Desc.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
            TC_Qty.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Quantity, "{0:N0}");
            TC_Unit.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Unit);
            TC_UnitPrice.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_UnitPrice, currencySign + "{0:0.00}");
            TC_Amount.DataBindings.Add("Text", this.DataSource, Model.ProformaInvoiceDetail.PRO_Amount, currencySign + "{0:N2}");
        }
Exemplo n.º 10
0
 public EditFormProformaInvoice(Model.ProformaInvoice invoice)
     : this()
 {
     if (invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.proformaInvoice = invoice;
     this.action          = "view";
     if (this.action == "view")
     {
         LastFlag = 1;
     }
 }
Exemplo n.º 11
0
 int LastFlag = 0; //页面载 入时是否执行 last方法
 public EditFormProformaInvoice(string invoiceId)
     : this()
 {
     this.proformaInvoice = this.proformaInvoiceManager.Get(invoiceId);
     if (this.proformaInvoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.action = "view";
     if (this.action == "view")
     {
         LastFlag = 1;
     }
 }
Exemplo n.º 12
0
 private void Validate(Model.ProformaInvoice model)
 {
     if (string.IsNullOrEmpty(model.PO))
     {
         throw new Helper.RequireValueException(Model.ProformaInvoice.PRO_PO);
     }
     if (model.InvoiceDate == null)
     {
         throw new Helper.RequireValueException(Model.ProformaInvoice.PRO_InvoiceDate);
     }
     if (string.IsNullOrEmpty(model.CustomerId))
     {
         throw new Helper.RequireValueException(Model.ProformaInvoice.PRO_CustomerId);
     }
 }
Exemplo n.º 13
0
 protected override void TurnNull()
 {
     if (this.proformaInvoice == null)
     {
         return;
     }
     if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         this.proformaInvoiceManager.Delete(this.proformaInvoice.PO);
         this.proformaInvoice = this.proformaInvoiceManager.GetNext(this.proformaInvoice);
         if (this.proformaInvoice == null)
         {
             this.proformaInvoice = this.proformaInvoiceManager.GetLast();
         }
     }
 }
Exemplo n.º 14
0
 public void Update(Model.ProformaInvoice e)
 {
     this.Update <Model.ProformaInvoice>(e);
 }
Exemplo n.º 15
0
 public bool HasRowsBefore(Model.ProformaInvoice e)
 {
     return(accessor.HasRowsBefore(e));
 }
Exemplo n.º 16
0
 protected override void MoveFirst()
 {
     this.proformaInvoice = this.proformaInvoiceManager.GetFirst();
 }
Exemplo n.º 17
0
 public bool HasRowsAfter(Model.ProformaInvoice e)
 {
     return(accessor.HasRowsAfter(e));
 }
Exemplo n.º 18
0
        public override void Refresh()
        {
            if (this.proformaInvoice == null)
            {
                this.AddNew();
            }
            else
            {
                if (this.action == "view")  //打印時去掉PLTNO,修改時刷新一下顯示出來
                {
                    this.proformaInvoice = this.proformaInvoiceManager.GetDetail(this.proformaInvoice.PO);
                }
            }

            this.txt_PONo.Text = this.proformaInvoice.PO;
            this.Date_InvoiceDate.EditValue = this.proformaInvoice.InvoiceDate;
            this.ncc_Customer.EditValue     = this.proformaInvoice.Customer;
            if (this.ncc_Customer.EditValue != null)
            {
                this.txt_CustomerAddress.Text = this.proformaInvoice.Customer.CustomerAddress;
                this.txt_Tel.Text             = this.proformaInvoice.Customer.CustomerPhone;
                this.txt_Attn.Text            = this.proformaInvoice.Customer.CustomerContact;
                this.txt_PaymentTerm.Text     = this.proformaInvoice.Customer.PayCondition;
            }
            else
            {
                this.txt_CustomerAddress.Text = "";
                this.txt_Tel.Text             = "";
                this.txt_Attn.Text            = "";
                this.txt_PaymentTerm.Text     = "";
            }
            this.txt_Attn.Text             = this.proformaInvoice.Attn;
            this.lue_AccountName.EditValue = this.proformaInvoice.BankId;

            this.txt_CustomerPONo.Text    = this.proformaInvoice.CustomerPONo;
            this.txt_SalesRep.Text        = this.proformaInvoice.SalesRep;
            this.txt_TotalEnglish.Text    = this.proformaInvoice.TotalEnglish;
            this.txt_GoodsReadyDate.Text  = this.proformaInvoice.GOODSREADYDATE;
            this.txt_CountryOfOrigin.Text = this.proformaInvoice.COUNTRYOFORIGIN;

            switch (this.action)
            {
            case "insert":
                this.gridView3.OptionsBehavior.Editable = true;
                break;

            case "update":
                this.gridView3.OptionsBehavior.Editable = true;
                break;

            default:
                this.gridView3.OptionsBehavior.Editable = false;
                break;
            }

            this.bindingSourceDetail.DataSource = this.proformaInvoice.Details;

            base.Refresh();

            if (this.action == "update")
            {
                this.txt_PONo.Properties.ReadOnly = true;
            }
        }
Exemplo n.º 19
0
 public Model.ProformaInvoice GetPrev(Model.ProformaInvoice e)
 {
     return(accessor.GetPrev(e));
 }
Exemplo n.º 20
0
 public Model.ProformaInvoice GetPrev(Model.ProformaInvoice e)
 {
     return(sqlmapper.QueryForObject <Model.ProformaInvoice>("ProformaInvoice.get_prev", e));
 }
Exemplo n.º 21
0
 public Model.ProformaInvoice GetNext(Model.ProformaInvoice e)
 {
     return(sqlmapper.QueryForObject <Model.ProformaInvoice>("ProformaInvoice.get_next", e));
 }
Exemplo n.º 22
0
 public bool HasRowsAfter(Model.ProformaInvoice e)
 {
     return(sqlmapper.QueryForObject <bool>("ProformaInvoice.has_rows_after", e));
 }
Exemplo n.º 23
0
 public bool HasRowsBefore(Model.ProformaInvoice e)
 {
     return(sqlmapper.QueryForObject <bool>("ProformaInvoice.has_rows_before", e));
 }
Exemplo n.º 24
0
 public Model.ProformaInvoice GetNext(Model.ProformaInvoice e)
 {
     return(accessor.GetNext(e));
 }
Exemplo n.º 25
0
 public void Insert(Model.ProformaInvoice e)
 {
     this.Insert <Model.ProformaInvoice>(e);
 }
Exemplo n.º 26
0
        public override void Refresh()
        {
            if (this.proformaInvoice == null)
            {
                this.AddNew();
            }
            else
            {
                if (this.action == "view")  //打印時去掉PLTNO,修改時刷新一下顯示出來
                {
                    this.proformaInvoice = this.proformaInvoiceManager.GetDetail(this.proformaInvoice.PO);
                }
            }

            this.txt_PONo.Text = this.proformaInvoice.PO;
            this.Date_InvoiceDate.EditValue = this.proformaInvoice.InvoiceDate;
            this.ncc_Customer.EditValue     = this.proformaInvoice.Customer;
            if (this.ncc_Customer.EditValue != null)
            {
                this.txt_CustomerAddress.Text = this.proformaInvoice.Customer.CustomerAddress;
                this.txt_Tel.Text             = this.proformaInvoice.Customer.CustomerPhone;
                this.txt_Attn.Text            = this.proformaInvoice.Customer.CustomerContact;
                this.txt_TERM.Text            = this.proformaInvoice.Customer.TradingCondition;
                this.txt_PaymentTerm.Text     = this.proformaInvoice.Customer.PayCondition;
            }
            else
            {
                this.txt_CustomerAddress.Text = "";
                this.txt_Tel.Text             = "";
                this.txt_Attn.Text            = "";
                this.txt_TERM.Text            = "";
                this.txt_PaymentTerm.Text     = "";
            }
            this.txt_DeliveryTo.EditValue  = this.proformaInvoice.DeliveryTo;
            this.txt_Attn.Text             = this.proformaInvoice.Attn;
            this.cob_Currency.Text         = this.proformaInvoice.Currency;
            this.txt_Remark.Text           = this.proformaInvoice.Remark;
            this.txt_Deliverydate.Text     = this.proformaInvoice.DeliveryDate;
            this.lue_AccountName.EditValue = this.proformaInvoice.BankId;
            this.me_ShippimgMark.Text      = this.proformaInvoice.ShippimgMark;

            switch (this.action)
            {
            case "insert":
                this.gridView3.OptionsBehavior.Editable = true;
                break;

            case "update":
                this.gridView3.OptionsBehavior.Editable = true;
                break;

            default:
                this.gridView3.OptionsBehavior.Editable = false;
                break;
            }

            this.bindingSourceDetail.DataSource = this.proformaInvoice.Details;

            base.Refresh();

            if (this.action == "update")
            {
                this.txt_PONo.Properties.ReadOnly = true;
            }
        }