Ejemplo n.º 1
0
        protected void btnSettlement_Click(object sender, EventArgs e)
        {
            //get no
            SeedDAL sdal = new SeedDAL();
            string  no   = sdal.GetNoByTableName(SysConst.TableSettlement, SysConst.SuffixSettlement);

            string companyName = string.Empty;
            string contact     = string.Empty;
            string address     = string.Empty;
            string email       = string.Empty;
            string qq          = string.Empty;
            string phone1      = string.Empty;
            string phone2      = string.Empty;
            string other       = string.Empty;

            OrderDAL soDAL = new OrderDAL();
            var      so    = soDAL.GetOrderByNo(SourceNo);

            companyName = so.CustomerCompanyName;
            contact     = so.CustomerContactName;
            address     = so.CustomerAddress;
            email       = so.CustomerEmail;
            qq          = so.CustomerQQ;
            phone1      = so.CustomerPhone1;
            phone2      = so.CustomerPhone2;
            other       = so.CustomerOthers;

            //new refine
            SettlementDAL dal = new SettlementDAL();
            Settlement    st  = new Settlement()
            {
                St_No               = no,
                Status              = FirstStatusConsts.Settlement,
                SourceType          = SourceType,
                SourceNo            = SourceNo,
                CreatedDate         = DateTime.Now,
                CustomerCompanyName = companyName,
                CustomerContactName = contact,
                CustomerAddress     = address,
                CustomerEmail       = email,
                CustomerQQ          = qq,
                CustomerPhone1      = phone1,
                CustomerPhone2      = phone2,
                CustomerOthers      = other
            };

            dal.AddSettlement(st);
            dal.Save();

            int    stid   = st.St_Id;
            string stno   = st.St_No;
            string url    = Page.ResolveUrl(string.Format("~/SettlementForm.aspx?stid={0}&stno={1}&sourcetype={2}&sourceno={3}", stid, stno, SysConst.SourceTypeOrder, SourceNo));
            string script = string.Format("<script>window.open('{0}')</script>", url);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createsettle", script);
            BindControl();
            SetFocus(btnSettlement);
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SettlementDAL dal = new SettlementDAL();
            var           st  = dal.GetSettlementByNo(StNo);

            if (!string.IsNullOrEmpty(txtDeliveryDate.Text))
            {
                st.DeliveryDate = DateTime.Parse(txtDeliveryDate.Text);
            }
            //update st
            st.StMan = Utility.GetSelectedText(ddlSettlementMan);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < cblDeliveryList.Items.Count; i++)
            {
                if (cblDeliveryList.Items[i].Selected)
                {
                    sb.Append(cblDeliveryList.Items[i].Text).Append("|");
                }
            }
            st.DeliveryList = sb.ToString();
            st.StLocation   = txtSettleLocation.Text;

            st.CustomerCompanyName = customerInfoControl.CompanyName;
            st.CustomerContactName = customerInfoControl.ContactName;
            st.CustomerAddress     = customerInfoControl.Address;
            st.CustomerEmail       = customerInfoControl.Email;
            st.CustomerQQ          = customerInfoControl.QQ;
            st.CustomerPhone1      = customerInfoControl.Phone1;
            st.CustomerPhone2      = customerInfoControl.Phone2;
            st.CustomerOthers      = customerInfoControl.Other;
            //settlement
            if (!string.IsNullOrEmpty(txtTotalAmount.Text))
            {
                st.TotalAmount = double.Parse(txtTotalAmount.Text);
            }
            if (!string.IsNullOrEmpty(txtReceivedFirst.Text))
            {
                st.FirstAmount = double.Parse(txtReceivedFirst.Text);
            }
            if (!string.IsNullOrEmpty(txtReceived.Text))
            {
                st.AmountReceived = double.Parse(txtReceived.Text);
            }
            st.ReceivableIntro = txtBalanceIntro.Text;
            AddFollowUp(followUpControl, st.Status, Utility.GetSelectedText(ddlSettlementStatus));
            st.Status = Utility.GetSelectedText(ddlSettlementStatus);

            dal.Save();
            //save new customer
            customerInfoControl.Save();
            this.SetFocus(sender);
        }
Ejemplo n.º 3
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            SettlementDAL dal  = new SettlementDAL();
            LineItemDAL   lDal = new LineItemDAL();

            var             settlement = dal.GetSettlementById(StId);
            StringBuilder   sb         = new StringBuilder(256);
            List <LineItem> lineItems  = new List <LineItem>();

            foreach (ListItem item in cblDeliveryList.Items)
            {
                if (item.Selected)
                {
                    sb.Append(item.Text).Append("|");
                    lineItems.AddRange(lDal.GetLineItemsBySource(int.Parse(item.Value), SysConst.SourceTypeDelivery));
                }
            }
            settlement.DeliveryList = sb.ToString();

            dal.Save();


            var dbItems = lDal.GetLineItemsBySource(this.StId, SysConst.SourceTypeSettlement);

            foreach (var item in dbItems)
            {
                lDal.DeleteItem(item.LineItem_Id);
            }

            foreach (var item in lineItems)
            {
                LineItem li = new LineItem()
                {
                    Intro      = item.Intro,
                    Name       = item.Name,
                    OriginNo   = item.OriginNo,
                    Project    = item.Project,
                    Quantity   = item.Quantity,
                    Remark     = item.Remark,
                    SourceId   = this.StId,
                    SourceType = SysConst.SourceTypeSettlement,
                    Spec       = item.Spec,
                    Unit       = item.Unit,
                    UnitPrice  = item.UnitPrice
                };
                lDal.AddLineItem(li);
            }
            lDal.Save();

            UIUtility.BindUserControl(LineItemsControl1, SysConst.SourceTypeSettlement, StId);
        }
Ejemplo n.º 4
0
        protected void btnSaveAmount_Click(object sender, EventArgs e)
        {
            SettlementDAL dal = new SettlementDAL();
            var           st  = dal.GetSettlementByNo(StNo);

            if (!string.IsNullOrEmpty(txtTotalAmount.Text))
            {
                st.TotalAmount = double.Parse(txtTotalAmount.Text);
            }
            if (!string.IsNullOrEmpty(txtReceivedFirst.Text))
            {
                st.FirstAmount = double.Parse(txtReceivedFirst.Text);
            }
            if (!string.IsNullOrEmpty(txtReceived.Text))
            {
                st.AmountReceived = double.Parse(txtReceived.Text);
            }
            st.ReceivableIntro = txtBalanceIntro.Text;
            lblEndBalance.Text = ((st.TotalAmount.HasValue ? st.TotalAmount.Value : 0) - (st.AmountReceived.HasValue ? st.AmountReceived.Value : 0)).ToString();
            dal.Save();
        }
Ejemplo n.º 5
0
        protected void cblDeliveryList_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <LineItem> items = new List <LineItem>();
            LineItemDAL     dal   = new LineItemDAL();

            foreach (ListItem listItem in cblDeliveryList.Items)
            {
                if (listItem.Selected)
                {
                    var del      = new DeliveryDAL().GetDeliveryByNo(listItem.Text);
                    var delItems = dal.GetLineItemsBySource(del.Delivery_Id, SysConst.SourceTypeDelivery);
                    foreach (var delItem in delItems)
                    {
                        items.Add(new LineItem()
                        {
                            Intro      = delItem.Intro,
                            Name       = delItem.Name,
                            OriginNo   = listItem.Text,
                            Project    = delItem.Project,
                            Quantity   = delItem.Quantity,
                            Remark     = delItem.Remark,
                            SourceId   = StId,
                            SourceType = SysConst.SourceTypeSettlement,
                            Spec       = delItem.Spec,
                            Unit       = delItem.Unit,
                            UnitPrice  = delItem.UnitPrice
                        });
                    }
                }
                else
                {
                    var lineItemsOfSt = dal.GetLineItemsBySource(StId, SysConst.SourceTypeSettlement);
                    foreach (var item in lineItemsOfSt)
                    {
                        if (item.OriginNo == listItem.Text)
                        {
                            dal.DeleteItem(item.LineItem_Id);
                        }
                    }
                }
            }
            foreach (var item in items)
            {
                dal.AddLineItem(item);
            }
            dal.Save();

            //save list
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < cblDeliveryList.Items.Count; i++)
            {
                if (cblDeliveryList.Items[i].Selected)
                {
                    sb.Append(cblDeliveryList.Items[i].Text).Append("|");
                }
            }
            var stDAL = new SettlementDAL();
            var st    = stDAL.GetSettlementByNo(StNo);

            st.DeliveryList = sb.ToString();
            stDAL.Save();

            UIUtility.BindUserControl(LineItemsControl1, SysConst.SourceTypeSettlement, StId);
        }