public override void BindControl()
        {
            MachSummaryDAL dal    = new MachSummaryDAL();
            var            result = dal.GetSummaryByMachId(MachId);

            Utility.BindDataToRepeater(rpItems, result);
        }
        protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            MachSummaryDAL dal  = new MachSummaryDAL();
            MachLookupDAL  lDAL = new MachLookupDAL();

            if (e.CommandName == "Add")
            {
                TextBox      txtMachIntroAdd = e.Item.FindControl("txtMachIntroAdd") as TextBox;
                DropDownList ddlMachNameAdd  = e.Item.FindControl("ddlMachNameAdd") as DropDownList;
                DropDownList ddlMachUnitAdd  = e.Item.FindControl("ddlMachUnitAdd") as DropDownList;
                TextBox      txtQtyAdd       = e.Item.FindControl("txtQtyAdd") as TextBox;
                TextBox      txtRemarkAdd    = e.Item.FindControl("txtRemarkAdd") as TextBox;


                MachSummary summary = new MachSummary();
                summary.MachId    = MachId;
                summary.MachIntro = txtMachIntroAdd.Text;
                summary.MachName  = Utility.GetSelectedText(ddlMachNameAdd);
                summary.Unit      = Utility.GetSelectedText(ddlMachUnitAdd);
                summary.Qty       = !string.IsNullOrEmpty(txtQtyAdd.Text) ? int.Parse(txtQtyAdd.Text) : 0;
                summary.Remark    = txtRemarkAdd.Text;
                summary.ImagePath = lDAL.GetMachLookupById(int.Parse(Utility.GetSelectedValue(ddlMachNameAdd))).MachIdentity;
                dal.AddMachSummary(summary);
                dal.Save();
            }
            else if (e.CommandName == "Save")
            {
                HiddenField hdId    = e.Item.FindControl("hdId") as HiddenField;
                MachSummary summary = dal.GetSummaryById(int.Parse(hdId.Value));

                TextBox      txtMachIntro = e.Item.FindControl("txtMachIntro") as TextBox;
                DropDownList ddlMachName  = e.Item.FindControl("ddlMachName") as DropDownList;
                DropDownList ddlMachUnit  = e.Item.FindControl("ddlMachUnit") as DropDownList;
                TextBox      txtQty       = e.Item.FindControl("txtQty") as TextBox;
                TextBox      txtRemark    = e.Item.FindControl("txtRemark") as TextBox;

                summary.MachIntro = txtMachIntro.Text;
                summary.MachName  = Utility.GetSelectedText(ddlMachName);
                summary.Unit      = Utility.GetSelectedText(ddlMachUnit);
                summary.Qty       = !string.IsNullOrEmpty(txtQty.Text) ? int.Parse(txtQty.Text) : 0;
                summary.Remark    = txtRemark.Text;
                summary.ImagePath = lDAL.GetMachLookupById(int.Parse(Utility.GetSelectedValue(ddlMachName))).MachIdentity;

                dal.Save();
            }
            else if (e.CommandName == "Delete")
            {
                HiddenField hdId = e.Item.FindControl("hdId") as HiddenField;
                dal.DeleteSummary(int.Parse(hdId.Value));
            }

            BindControl();
            SetFocus(btnLoc);
        }
        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);
        }