protected void btnSave_Click(object sender, EventArgs e)
        {
            RefineDAL dal    = new RefineDAL();
            var       refine = dal.GetRefineByNo(RefNo);

            refine.RefineMan = Utility.GetSelectedText(ddlRefMan);
            if (!string.IsNullOrEmpty(txtCompletedDate.Text))
            {
                refine.RequestCompleteDate = DateTime.Parse(txtCompletedDate.Text);
            }
            AddFollowUp(followUpControl, refine.Status, Utility.GetSelectedText(ddlRefineStatus));
            refine.Status = Utility.GetSelectedText(ddlRefineStatus);
            refine.NeedCustomerConfirm  = chkConfirm.Checked;
            refine.CustomerConfirmIntro = txtConfirmIntro.Text;
            refine.IncludeMaching       = chkIncludeMachining.Checked;
            refine.NeedApprove          = chkNeedApprove.Checked;
            refine.RefineIntro          = txtRefineIntro.Text;
            refine.CustomerCompanyName  = customerInfoControl.CompanyName;
            refine.CustomerContactName  = customerInfoControl.ContactName;
            refine.CustomerAddress      = customerInfoControl.Address;
            refine.CustomerQQ           = customerInfoControl.QQ;
            refine.CustomerEmail        = customerInfoControl.Email;
            refine.CustomerPhone1       = customerInfoControl.Phone1;
            refine.CustomerPhone2       = customerInfoControl.Phone2;
            refine.CustomerOthers       = customerInfoControl.Other;

            dal.Save();
            //save new customer
            customerInfoControl.Save();
            SetFocus(sender);
        }
        protected void btnChangeStatus_Click(object sender, EventArgs e)
        {
            RefineDAL dal    = new RefineDAL();
            var       refine = dal.GetRefineById(RefId);

            AddFollowUp(followUpControl, refine.Status, Utility.GetSelectedText(ddlRefineStatus));
            refine.Status = Utility.GetSelectedText(ddlRefineStatus);
            dal.Save();
            SetFocus(btnChangeStatus);
        }
        protected void btnCreateCADRefinement_Click(object sender, EventArgs e)
        {
            //get no
            SeedDAL sdal = new SeedDAL();
            string  no   = sdal.GetNoByTableName(SysConst.TableRefine, SysConst.SuffixRefine);
            //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;
            string enqNo       = string.Empty;

            if (string.Equals(SourceType, SysConst.SourceTypeEnquiry, StringComparison.OrdinalIgnoreCase))
            {
                EnquiryDAL enqDAL = new EnquiryDAL();
                var        enq    = enqDAL.GetEnquiryByNo(SourceNo);
                enqOrdMan   = enq.EnqMan;
                companyName = enq.CustomerCompanyName;
                contact     = enq.CustomerContactName;
                address     = enq.CustomerAddress;
                email       = enq.CustomerEmail;
                qq          = enq.CustomerQQ;
                phone1      = enq.CustomerPhone1;
                phone2      = enq.CustomerPhone2;
                other       = enq.CustomerOthers;
                enqNo       = SourceNo;
                //update enq status
                enq.Status = "申请CAD细化";
                enqDAL.Save();
            }
            if (string.Equals(SourceType, SysConst.SourceTypeSalesOrder, StringComparison.OrdinalIgnoreCase))
            {
                OrderDAL soDAL = new OrderDAL();
                var      so    = soDAL.GetOrderByNo(SourceNo);
                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;
                enqNo       = so.EnqNo;
                //update enq status
                so.Status = "申请CAD细化";
                soDAL.Save();
            }
            //new refine
            RefineDAL dal    = new RefineDAL();
            Refine    refine = new Refine()
            {
                Refine_No           = no,
                Status              = FirstStatusConsts.Refine,
                EnqOrdMan           = enqOrdMan,
                SourceType          = SourceType,
                SourceNo            = SourceNo,
                CreatedDate         = DateTime.Now,
                CreatedAt           = DateTime.Now,
                CreatedBy           = SMSContext.Current.User.UserName,
                CustomerCompanyName = companyName,
                CustomerContactName = contact,
                CustomerAddress     = address,
                CustomerEmail       = email,
                CustomerQQ          = qq,
                CustomerPhone1      = phone1,
                CustomerPhone2      = phone2,
                CustomerOthers      = other,
                EnqNo = enqNo
            };

            dal.AddRefine(refine);
            dal.Save();

            int    refid  = refine.Refine_Id;
            string refno  = refine.Refine_No;
            string url    = Page.ResolveUrl(string.Format("~/RefineForm.aspx?refid={0}&refno={1}&sourcetype={2}&sourceno={3}", refid, refno, SourceType, SourceNo));
            string script = string.Format("<script>window.open('{0}')</script>", url);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createrefine", script);
            BindControl();
            SetFocus(btnCreateCADRefinement);
        }