Exemple #1
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);
        }
        protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            LineItemDAL dal = new LineItemDAL();

            if (e.CommandName == "Save")
            {
                HiddenField hdId           = e.Item.FindControl("hdId") as HiddenField;
                TextBox     txtIntro       = e.Item.FindControl("txtIntro") as TextBox;
                TextBox     txtProductName = e.Item.FindControl("txtProductName") as TextBox;
                TextBox     txtSpec        = e.Item.FindControl("txtSpec") as TextBox;
                TextBox     txtUnit        = e.Item.FindControl("txtUnit") as TextBox;
                TextBox     txtPrice       = e.Item.FindControl("txtPrice") as TextBox;
                TextBox     txtQty         = e.Item.FindControl("txtQty") as TextBox;
                TextBox     txtRemark      = e.Item.FindControl("txtRemark") as TextBox;
                var         lineItem       = dal.GetLineItemById(int.Parse(hdId.Value));

                lineItem.Intro     = txtIntro.Text;
                lineItem.Name      = txtProductName.Text;
                lineItem.Spec      = txtSpec.Text;
                lineItem.Unit      = txtUnit.Text;
                lineItem.UnitPrice = !string.IsNullOrEmpty(txtPrice.Text) ? double.Parse(txtPrice.Text) : 0;
                lineItem.Quantity  = !string.IsNullOrEmpty(txtQty.Text) ? double.Parse(txtQty.Text) : 0;
                lineItem.Remark    = txtRemark.Text;
                dal.Save();
            }
            if (e.CommandName == "Delete")
            {
                HiddenField hdId = e.Item.FindControl("hdId") as HiddenField;
                dal.DeleteItem(int.Parse(hdId.Value));
            }
            BindControl();
            if (UpdateAmount != null)
            {
                UpdateAmount(SourceType, SourceId);
            }
            SetFocus(source);
        }
Exemple #3
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);
        }
        protected void btnImport_Click(object sender, EventArgs e)
        {
            DeliveryDAL    dal   = new DeliveryDAL();
            LineItemDAL    lDal  = new LineItemDAL();
            MachSummaryDAL mDAL  = new MachSummaryDAL();
            MachLookupDAL  mlDAL = new MachLookupDAL();

            var                delivery        = dal.GetDeliveryByNo(DeliveryNo);
            StringBuilder      sb              = new StringBuilder(256);
            List <MachSummary> machSummaryList = new List <MachSummary>();

            foreach (ListItem item in cblMach.Items)
            {
                if (item.Selected)
                {
                    sb.Append(item.Text).Append("|");
                    machSummaryList.AddRange(mDAL.GetSummaryByMachId(int.Parse(item.Value)));
                }
            }
            delivery.MachList = sb.ToString();
            dal.Save();


            var lineItems = lDal.GetLineItemsBySource(this.DeliveryId, SysConst.SourceTypeDelivery);

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

            foreach (var item in machSummaryList)
            {
                var machLook = mlDAL.GetMachLookupByName(item.MachName);
                var lineItem = new LineItem();
                lineItem.Intro      = item.MachIntro;
                lineItem.Name       = "加工";
                lineItem.Project    = item.MachName;
                lineItem.Quantity   = item.Qty;
                lineItem.Remark     = item.Remark;
                lineItem.SourceId   = DeliveryId;
                lineItem.SourceType = SysConst.SourceTypeDelivery;
                lineItem.Spec       = string.Empty;
                lineItem.Unit       = item.Unit;
                if (string.Equals(item.Unit, "米"))
                {
                    lineItem.UnitPrice = machLook.PriceM;
                }
                else if (string.Equals(item.Unit, "平方米"))
                {
                    lineItem.UnitPrice = machLook.PriceM2;
                }
                else
                {
                    lineItem.UnitPrice = machLook.PriceOther;
                }
                lDal.AddLineItem(lineItem);
            }

            lDal.Save();

            UIUtility.BindUserControl(lineItemControl, SysConst.SourceTypeDelivery, DeliveryId);
        }