Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ASPxComboBox cbGCH = ASPxPopupControl1.FindControl("LLGCH") as ASPxComboBox;

            if (cbGCH == null)
            {
                return;
            }
            ASPxComboBox cbGZH = ASPxPopupControl1.FindControl("LLGZH") as ASPxComboBox;

            if (cbGZH == null)
            {
                return;
            }
            ASPxTextBox txtPGDH = ASPxPopupControl1.FindControl("LLPGDH") as ASPxTextBox;

            if (txtPGDH == null)
            {
                return;
            }
            ASPxTextBox txtXMDH = ASPxPopupControl1.FindControl("LLXMDH") as ASPxTextBox;

            if (txtXMDH == null)
            {
                return;
            }
            ASPxTextBox txtXMMC = ASPxPopupControl1.FindControl("LLXMMC") as ASPxTextBox;

            if (txtXMMC == null)
            {
                return;
            }
            ASPxTextBox txtLLSL = ASPxPopupControl1.FindControl("LLSL") as ASPxTextBox;

            if (txtLLSL == null)
            {
                return;
            }
            ASPxComboBox cbTEAM = ASPxPopupControl1.FindControl("LLZPXZ") as ASPxComboBox;

            if (cbTEAM == null)
            {
                return;
            }
            ASPxDateEdit cbLLRQ = ASPxPopupControl1.FindControl("LYRQ") as ASPxDateEdit;

            if (cbLLRQ == null)
            {
                return;
            }
            ASPxTextBox txtXMLX = ASPxPopupControl1.FindControl("LLXMLX") as ASPxTextBox;

            if (txtXMLX == null)
            {
                return;
            }

            string     project_code = cbGCH.SelectedItem.Value.ToString();
            string     work_code    = cbGZH.SelectedItem.Value.ToString();
            string     billno       = txtPGDH.Text;
            string     item_code    = txtXMDH.Text;
            string     item_name    = txtXMMC.Text;
            int        item_qty     = Convert.ToInt32(txtLLSL.Text);
            string     team_cdoe    = cbTEAM.SelectedItem.Value.ToString();
            string     llxmlx       = txtXMLX.Text;
            DateTime   need_date    = cbLLRQ.Date;
            UserEntity u            = UserFactory.GetByID(user.getUserId());
            TeamEntity t            = TeamFactory.GetByTeamCode(team_cdoe);
            UserEntity leader       = UserFactory.GetByUserCode(t.LEADER_CODE);

            if (string.IsNullOrWhiteSpace(project_code) || string.IsNullOrWhiteSpace(work_code) || string.IsNullOrWhiteSpace(billno) ||
                string.IsNullOrWhiteSpace(item_code) || string.IsNullOrWhiteSpace(team_cdoe) || string.IsNullOrWhiteSpace(item_name) ||
                string.IsNullOrWhiteSpace(llxmlx))
            {
                return;
            }
            if (item_qty < 1 || item_qty > 999999)
            {
                return;
            }
            if ((need_date - DateTime.Now).TotalMinutes < 0)
            {
                return;
            }

            ProjectEntity         project   = ProjectFactory.GetByProjectCode(project_code);
            List <WorkShopEntity> workshops = WorkShopFactory.GetUserWorkShops(user.getUserId());

            if (workshops.Count > 0)
            {
                workshop = workshops[0];
            }
            else
            {
                return;
            }

            if (project != null)
            {
                string barCode = DB.GetInstance().ExecuteScalar <string>("select 'RMESL'||TRIM(TO_CHAR(SEQ_ISSUE_BARCODE.NEXTVAL,'0000000000')) from dual");

                InterIssueEntity interEntity = new InterIssueEntity
                {
                    LLGCH     = project_code,                    //领料合同号
                    LLGZH     = work_code,                       //领料工作号
                    LLCPXH    = project.PRODUCT_SERIES,          //领料产品型号
                    LLZJDH    = "MANUAL",                        //领料组件代号
                    PLAN_CODE = "R" + billno,                    //领料派工单号 - 临改单
                    LLLYDW    = workshop.WORKSHOP_CODE,          //领用单位 - 车间
                    LLZPXZ    = team_cdoe,                       //装配小组
                    LLXH      = 1,                               //领料序号
                    LLXMDH    = item_code,                       //项目代号 - 图号
                    LLLYPC    = "1",                             //领用批次
                    LLSL      = item_qty,                        //领料数量
                    LLCJYH    = u.USER_CODE + "/" + u.USER_NAME, //单据创建人
                    LLCJRQ    = DateTime.Now,                    //单据创建日期
                    LLNY      = need_date.ToString("yyMM"),      //领料年月
                    LLRQ      = need_date,                       //领料日期
                    LLXMMC    = item_name,                       //领料项目名称
                    TMBH      = barCode,                         //领料条码编号
                    LLBS      = "W",                             //领料标识
                    LLXZZZ    = leader.USER_CODE + "/" + leader.USER_NAME,
                    LLSPYH    = u.USER_CODE + "/" + u.USER_NAME,
                    LLR       = leader.USER_CODE + "/" + leader.USER_NAME,
                    LLXMLX    = llxmlx.ToUpper()
                };
                object obj = DB.GetInstance().Insert("INTER_ISSUE", "", false, interEntity);
                if (obj.ToString().ToUpper().Equals("TRUE"))
                {
                    Response.Write("<script>alert('添加成功!');</script>");
                    Response.Redirect(Request.Url.ToString());
                }
            }
        }