Пример #1
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            string url   = Request.Url.AbsoluteUri.Replace("MachiningForm", "snapshot");
            Thread NewTh = new Thread(new ParameterizedThreadStart(ExportImg));

            NewTh.SetApartmentState(ApartmentState.STA);
            NewTh.Start(url);
            while (NewTh.ThreadState == ThreadState.Running)
            {
            }
            MachiningDAL dal  = new MachiningDAL();
            var          mach = dal.GetMachById(MachId);

            string fileName = string.Format("{0}.jpg", mach.Mach_No);
            string filePath = Server.MapPath(string.Format("~/ImgLib/{0}", fileName));

            FileStream fs = new FileStream(filePath, FileMode.Open);

            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            Response.ContentType = "application/octet-stream";
            //通知浏览器下载文件而不是打开
            Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
        }
Пример #2
0
        public override void BindControl()
        {
            MachiningDAL dal   = new MachiningDAL();
            var          machs = dal.GetMachBySource(SourceType, SourceNo);

            Utility.BindDataToRepeater(rpMachining, machs);
        }
Пример #3
0
        protected void btnChangeStatus_Click(object sender, EventArgs e)
        {
            MachiningDAL dal  = new MachiningDAL();
            var          mach = dal.GetMachByNo(MachNo);

            AddFollowUp(followUpControl, mach.Status, Utility.GetSelectedText(ddlMachiningStatus));
            SetFocus(btnChangeStatus);
        }
Пример #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MachiningDAL dal  = new MachiningDAL();
            var          mach = dal.GetMachByNo(MachNo);

            //update ord
            mach.MachCreateMan    = Utility.GetSelectedText(ddlMachCreateMan);
            mach.ProcessCreateMan = Utility.GetSelectedText(ddlMachTableMan);
            mach.SalesMan         = Utility.GetSelectedText(ddlSalesMan);
            mach.RefineMan        = Utility.GetSelectedText(ddlRefineMan);
            mach.SurveyMan        = Utility.GetSelectedText(ddlSurveyMan);
            mach.MachMan          = Utility.GetSelectedText(ddlMachProcessor);
            if (!string.IsNullOrEmpty(txtApplyDate.Text))
            {
                mach.ApplyDate = DateTime.Parse(txtApplyDate.Text);
            }

            if (!string.IsNullOrEmpty(txtExpectedCompletedDate.Text))
            {
                mach.ExpectedCompleteDate = DateTime.Parse(txtExpectedCompletedDate.Text);
            }
            if (!string.IsNullOrEmpty(txtCompletedDate.Text))
            {
                mach.CompleteDate = DateTime.Parse(txtCompletedDate.Text);
            }
            if (!string.IsNullOrEmpty(txtExpectedDeliveryDate.Text))
            {
                mach.ExpectedDeliveryDate = DateTime.Parse(txtExpectedDeliveryDate.Text);
            }
            if (!string.IsNullOrEmpty(txtExpectedInstallDate.Text))
            {
                mach.ExpectedInstallDate = DateTime.Parse(txtExpectedInstallDate.Text);
            }
            mach.MachIntro = txtMachiningSummary.Text;

            mach.CustomerCompanyName = customerInfoControl.CompanyName;
            mach.CustomerContactName = customerInfoControl.ContactName;
            mach.CustomerAddress     = customerInfoControl.Address;
            mach.CustomerEmail       = customerInfoControl.Email;
            mach.CustomerQQ          = customerInfoControl.QQ;
            mach.CustomerPhone1      = customerInfoControl.Phone1;
            mach.CustomerPhone2      = customerInfoControl.Phone2;
            mach.CustomerOthers      = customerInfoControl.Other;

            mach.IsRefineInstead = MachiningLineItem1.IsRefineInstead;
            mach.RefineNo        = MachiningLineItem1.RefineNo;
            mach.InsteadIntro    = MachiningLineItem1.RefineIntro;
            AddFollowUp(followUpControl, mach.Status, Utility.GetSelectedText(ddlMachiningStatus));
            mach.Status = Utility.GetSelectedText(ddlMachiningStatus);
            dal.Save();
            //save new customer
            customerInfoControl.Save();
            this.SetFocus(sender);
        }
Пример #5
0
        private List <Machining> GetMachList()
        {
            MachiningDAL dal    = new MachiningDAL();
            var          result = dal.SeachMachining(txtMachinineId.Text,
                                                     txtOrderId.Text,
                                                     Utility.GetSelectedText(ddlCreator),
                                                     Utility.GetSelectedText(ddlMachMan),
                                                     !string.IsNullOrEmpty(txtExpectedDateBegin.Text) ? DateTime.Parse(txtExpectedDateBegin.Text) : DateTime.MinValue,
                                                     !string.IsNullOrEmpty(txtExpectedDateEnd.Text) ? DateTime.Parse(txtExpectedDateEnd.Text) : DateTime.MaxValue,
                                                     Utility.GetSelectedText(ddlMachTableMan),
                                                     Utility.GetSelectedText(ddlMachiningStatus)
                                                     );

            return(result);
        }
Пример #6
0
        void ExportImg(object url)
        {
            WebPageSnapshot wps = new WebPageSnapshot();

            wps.Url = url.ToString();
            try
            {
                MachiningDAL dal      = new MachiningDAL();
                var          mach     = dal.GetMachById(MachId);
                string       fileName = string.Format("{0}.jpg", mach.Mach_No);
                wps.TakeSnapshot().Save(Server.MapPath("~/ImgLib/") + "\\" + fileName);
            }
            catch (Exception ex)
            {
            }
            wps.Dispose();
        }
Пример #7
0
        protected void btnCreateMachining_Click(object sender, EventArgs e)
        {
            //get no
            SeedDAL sdal = new SeedDAL();
            string  no   = sdal.GetNoByTableName(SysConst.TableMachining, SysConst.SuffixMachining);

            Machining mach = new Machining();

            mach.Mach_No     = no;
            mach.SourceNo    = SourceNo;
            mach.SourceType  = SourceType;
            mach.CreatedDate = DateTime.Now;
            mach.Status      = FirstStatusConsts.Mach;

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

            so.Status = "申请生产";
            soDAL.Save();

            mach.CustomerCompanyName = so.CustomerCompanyName;
            mach.CustomerContactName = so.CustomerContactName;
            mach.CustomerAddress     = so.CustomerAddress;
            mach.CustomerEmail       = so.CustomerEmail;
            mach.CustomerQQ          = so.CustomerQQ;
            mach.CustomerPhone1      = so.CustomerPhone1;
            mach.CustomerPhone2      = so.CustomerPhone2;
            mach.CustomerOthers      = so.CustomerOthers;

            MachiningDAL dal = new MachiningDAL();

            dal.AddMachining(mach);
            dal.Save();

            int    machId = mach.Mach_Id;
            string machNo = mach.Mach_No;
            string url    = Page.ResolveUrl(string.Format("~/MachiningForm.aspx?machid={0}&machno={1}&sourcetype={2}&sourceno={3}", machId, machNo, SourceType, SourceNo));
            string script = string.Format("<script>window.open('{0}')</script>", url);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createmach", script);
            BindControl();
            SetFocus(btnCreateMachining);
        }
        protected void btnCreatePurchase_Click(object sender, EventArgs e)
        {
            //get no
            SeedDAL sdal = new SeedDAL();
            string  no   = sdal.GetNoByTableName(SysConst.TablePurchaseOrder, SysConst.SuffixPurchaseOrder);
            //get enqordman
            string enqOrdMan   = string.Empty;
            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;

            if (string.Equals(SourceType, SysConst.SourceTypeOrder, StringComparison.OrdinalIgnoreCase))
            {
                OrderDAL soDAL = new OrderDAL();
                var      so    = soDAL.GetOrderByNo(SourceNo);
                so.Status = "申请采购";
                soDAL.Save();

                enqOrdMan   = so.OrderMan;
                companyName = so.CustomerCompanyName;
                contact     = so.CustomerContactName;
                address     = so.CustomerAddress;
                email       = so.CustomerEmail;
                qq          = so.CustomerQQ;
                phone1      = so.CustomerPhone1;
                phone2      = so.CustomerPhone2;
                other       = so.CustomerOthers;
            }
            else if (string.Equals(SourceType, SysConst.SourceTypeMaching, StringComparison.OrdinalIgnoreCase))
            {
                MachiningDAL mDAL = new MachiningDAL();
                var          mach = mDAL.GetMachByNo(SourceNo);
                companyName = mach.CustomerCompanyName;
                contact     = mach.CustomerContactName;
                address     = mach.CustomerAddress;
                email       = mach.CustomerEmail;
                qq          = mach.CustomerQQ;
                phone1      = mach.CustomerPhone1;
                phone2      = mach.CustomerPhone2;
                other       = mach.CustomerOthers;
            }
            //new refine
            PurchaseOrderDAL dal = new PurchaseOrderDAL();
            PurchaseOrder    po  = new PurchaseOrder()
            {
                Purchase_No = no,
                Status      = FirstStatusConsts.Purchase,
                EnqOrdMan   = enqOrdMan,
                SourceType  = SourceType,
                SourceNo    = SourceNo,
                CreatedDate = DateTime.Now,
                CreatedAt   = DateTime.Now,
                CreatedBy   = SMSContext.Current.User.UserName
            };

            dal.AddPO(po);
            dal.Save();

            int    poid = po.Purchase_Id;
            string pono = po.Purchase_No;

            //poitem
            if (string.Equals(SourceType, SysConst.SourceTypeMaching, StringComparison.OrdinalIgnoreCase))
            {
                MachiningDAL mDAL      = new MachiningDAL();
                var          mach      = mDAL.GetMachByNo(SourceNo);
                MachItemDAL  miDAL     = new MachItemDAL();
                var          machItems = miDAL.GetMachItemsByMachId(mach.Mach_Id);

                POItemDAL pDAL = new POItemDAL();
                foreach (var item in machItems)
                {
                    PurchaseOrderItem poItem = new PurchaseOrderItem()
                    {
                        Code         = item.Code,
                        Deepth       = item.Deepth,
                        Intro        = item.Intro,
                        Long         = item.Long,
                        PO_Id        = poid,
                        Product_Code = item.Product_Code,
                        Quantity     = item.Quantity,
                        Square       = item.Square,
                        Width        = item.Width
                    };
                    pDAL.AddPOItem(poItem);
                }
                pDAL.Save();
            }

            string url    = Page.ResolveUrl(string.Format("~/PurchaseForm.aspx?poid={0}&pono={1}&sourcetype={2}&sourceno={3}", poid, pono, SourceType, SourceNo));
            string script = string.Format("<script>window.open('{0}')</script>", url);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createpo", script);
            BindControl();
            SetFocus(btnCreatePurchase);
        }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility.BindDataToDropdown(ddlMachiningStatus, Utility.GetMachiningStatusList());
                Utility.BindDataToDropdown(ddlMachCreateMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlMachTableMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlSalesMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlRefineMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlSurveyMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlMachProcessor, Utility.GetUserList2(true));

                if (!string.IsNullOrWhiteSpace(MachNo))
                {
                    MachiningDAL dal  = new MachiningDAL();
                    var          mach = dal.GetMachByNo(MachNo);

                    OrderDAL sDAL  = new OrderDAL();
                    var      order = sDAL.GetOrderByNo(SourceNo);
                    lnkSource.NavigateUrl = Page.ResolveUrl(string.Format("~/OrderForm.aspx?ordno={0}&ordid={1}&sourceno={2}&sourcetype={3}", order.Order_No, order.Order_Id, order.SourceNo, order.SourceType));
                    lnkSource.Text        = SourceNo;

                    txtCreatedDate.Text            = mach.CreatedDate.ToString("yyyy-MM-dd");
                    ddlMachCreateMan.SelectedValue = mach.MachCreateMan;
                    ddlMachTableMan.SelectedValue  = mach.ProcessCreateMan;
                    ddlSalesMan.SelectedValue      = mach.SalesMan;
                    ddlRefineMan.SelectedValue     = mach.RefineMan;
                    ddlSurveyMan.SelectedValue     = mach.SurveyMan;
                    ddlMachProcessor.SelectedValue = mach.MachMan;
                    txtApplyDate.Text             = mach.ApplyDate.HasValue ? mach.ApplyDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    txtExpectedCompletedDate.Text = mach.ExpectedCompleteDate.HasValue ? mach.ExpectedCompleteDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    txtCompletedDate.Text         = mach.CompleteDate.HasValue ? mach.CompleteDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    txtExpectedDeliveryDate.Text  = mach.ExpectedDeliveryDate.HasValue ? mach.ExpectedDeliveryDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    txtExpectedInstallDate.Text   = mach.ExpectedInstallDate.HasValue ? mach.ExpectedInstallDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    txtMachiningSummary.Text      = mach.MachIntro;

                    //customer info
                    this.customerInfoControl.SetValue(
                        mach.CustomerCompanyName,
                        mach.CustomerContactName,
                        mach.CustomerAddress,
                        mach.CustomerEmail,
                        mach.CustomerQQ,
                        mach.CustomerPhone1,
                        mach.CustomerPhone2,
                        mach.CustomerOthers);
                    //history refine
                    UIUtility.BindUserControl(cADRefinementControl, SysConst.SourceTypeOrder, SourceNo);
                    //customer drawing
                    customerDrawingControl.IsCustomerProvideImage = order.IsCustomerProvideImage;
                    UIUtility.BindUserControl(customerDrawingControl, SysConst.SourceTypeOrder, order.Order_No);
                    //survey
                    UIUtility.BindUserControl(surveyControl, SysConst.SourceTypeOrder, SourceNo);
                    //purchase
                    UIUtility.BindUserControl(PurchaseControl1, SysConst.SourceTypeMaching, mach.Mach_No);
                    //machining table
                    MachiningLineItem1.IsRefineInstead = mach.IsRefineInstead;
                    MachiningLineItem1.RefineNo        = mach.RefineNo;
                    MachiningLineItem1.RefineIntro     = mach.InsteadIntro;
                    MachiningLineItem1.OrderNo         = order.Order_No;
                    MachiningLineItem1.MachId          = mach.Mach_Id;
                    UIUtility.BindUserControl(MachiningLineItem1, SysConst.SourceTypeMaching, mach.Mach_No);

                    //maching summary
                    MachiningSummaryControl1.MachId = mach.Mach_Id;
                    UIUtility.BindUserControl(MachiningSummaryControl1, SysConst.SourceTypeMaching, mach.Mach_No);
                    //status
                    ddlMachiningStatus.SelectedValue = mach.Status;
                    //followup
                    UIUtility.BindUserControl(followUpControl, SysConst.SourceTypeOrder, order.Order_No);
                }
            }
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility.BindDataToDropdown(ddlDeliveryStatus, Utility.GetDeliveryStatusList());
                Utility.BindDataToDropdown(ddlDeliveryMethod, Utility.GetLookupList(SysConst.DeliveryCatelog));
                Utility.BindDataToDropdown(ddlInstallType, Utility.GetLookupList(SysConst.InstallCatelog));
                Utility.BindDataToDropdown(ddlDelCreateMan, Utility.GetUserList2(true));
                Utility.BindDataToDropdown(ddlSalesMan, Utility.GetUserList2(true));

                if (!string.IsNullOrEmpty(DeliveryNo))
                {
                    DeliveryDAL  dDAL     = new DeliveryDAL();
                    var          del      = dDAL.GetDeliveryByNo(DeliveryNo);
                    OrderDAL     soDAL    = new OrderDAL();
                    var          ord      = soDAL.GetOrderByNo(SourceNo);
                    MachiningDAL mDAL     = new MachiningDAL();
                    var          machList = mDAL.GetMachBySource(SysConst.SourceTypeOrder, SourceNo);
                    foreach (var item in machList)
                    {
                        cblMach.Items.Add(new ListItem()
                        {
                            Text = item.Mach_No, Value = item.Mach_Id.ToString()
                        });
                    }
                    //basic
                    txtCreatedDate.Text           = del.CreatedDate.ToString("yyyy-MM-dd");
                    ddlSalesMan.SelectedValue     = del.OrderMan;
                    ddlDelCreateMan.SelectedValue = del.DeliveryCreateMan;
                    lnkOrder.Text        = SourceNo;
                    lnkOrder.NavigateUrl = Page.ResolveUrl(string.Format("~/OrderForm.aspx?ordid={0}&ordno={1}&sourcetype={2}&sourceno={3}",
                                                                         ord.Order_Id,
                                                                         ord.Order_No,
                                                                         ord.SourceType,
                                                                         ord.SourceNo));
                    if (!string.IsNullOrEmpty(del.MachList))
                    {
                        foreach (ListItem item in cblMach.Items)
                        {
                            if (del.MachList.Contains(item.Text))
                            {
                                item.Selected = true;
                            }
                        }
                    }
                    //customer
                    this.customerInfoControl.SetValue(
                        del.CustomerCompanyName,
                        del.CustomerContactName,
                        del.CustomerAddress,
                        del.CustomerEmail,
                        del.CustomerQQ,
                        del.CustomerPhone1,
                        del.CustomerPhone2,
                        del.CustomerOthers);
                    //delivery type
                    this.ddlDeliveryMethod.SelectedValue = del.DeliveryType;
                    this.txtDelIntro.Text           = del.DeliveryIntro;
                    this.txtDeliveryDriverMan.Text  = del.DeliveryDriverMan;
                    this.txtDelPhone.Text           = del.DriverPhone;
                    this.txtCarType.Text            = del.CarType;
                    this.txtDeliveryToAddress.Text  = del.DeliveryToAddress;
                    this.txtExpectDeliveryDate.Text = del.ExpectedDeliveryDate.HasValue ? del.ExpectedDeliveryDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    this.txtRealDelDate.Text        = del.RealDeliveryDate.HasValue ? del.RealDeliveryDate.Value.ToString("yyyy-MM-dd") : string.Empty;
                    //install
                    this.chkProvideInstall.Checked    = del.IsInstallProvided;
                    this.ddlInstallType.SelectedValue = del.InstallType;
                    this.txtInstallIntro.Text         = del.InstallIntro;
                    this.txtInstallMan.Text           = del.InstallMan;
                    this.txtInstallPhone.Text         = del.InstallPhone;
                    this.txtInstallDate.Text          = del.InstallDate.HasValue ? del.InstallDate.Value.ToString("yyyy-MM-dd"):string.Empty;
                    this.chkInsteadSettlement.Checked = del.InsteadOfSettlement;
                    //delivery content
                    lineItemControl.SourceId = del.Delivery_Id;
                    UIUtility.BindUserControl(lineItemControl, SysConst.SourceTypeDelivery, del.Delivery_No);
                    //settlement info
                    if (chkInsteadSettlement.Checked)
                    {
                        SettlementDAL dal = new SettlementDAL();
                        SetAmount(SysConst.SourceTypeDelivery, del.Delivery_Id);

                        txtTotalAmount.Text   = del.TotalAmount.ToString();
                        txtReceivedFirst.Text = del.FirstAmount.ToString();
                        txtReceived.Text      = del.ReceivedAmount.ToString();
                        txtBalanceIntro.Text  = del.ReceivableIntro;
                        lblEndBalance.Text    = ((del.TotalAmount.HasValue ? del.TotalAmount.Value : 0) - (del.ReceivedAmount.HasValue ? del.ReceivedAmount.Value : 0)).ToString();
                        var accumulateAmount = dal.GetSettlementByOrderNo(SourceNo).Where(s => s.CreatedDate <= del.CreatedDate).Sum(settle => settle.TotalAmount);
                        var receivableTotal  = new ReceiptDAL().GetReceiptBySource(SysConst.SourceTypeOrder, del.Order_No).Where(r => r.ReceivedDate <= del.CreatedDate).Sum(re => re.ReceivedAmount);
                        lblAccumulateAmount.Text = accumulateAmount.ToString();
                        lblReceivableTotal.Text  = receivableTotal.ToString();
                    }
                    //intro
                    UIUtility.BindUserControl(FooterIntroControl1, SysConst.SourceTypeDelivery, del.Delivery_No);
                    this.ddlDeliveryStatus.SelectedValue = del.Status;
                    //followup
                    UIUtility.BindUserControl(followUpControl, SysConst.SourceTypeDelivery, del.Delivery_No);
                }
            }
        }