Exemplo n.º 1
0
    protected void btnSaveClose_Click(object sender, EventArgs e)
    {
        #region//分批条码改为可以手动输入,判断条码是否已经存在 add by lei.xue on 2017-11-8
        string strExistSubLot = FilmCRUD.ExistSublot(txtLot.Text, txtLabelInfo.Text);
        if (strExistSubLot == "success")
        {
            JScript.Alert("该分批条码已经存在", this);
            return;
        }
        #endregion

        //插入basis表 , 更新母批剩余数量 ,子批flowidno为当点站
        string SplitLength = "";
        if (cbxSplit.Checked == true)
        {
            SplitLength = txtSplitLength.Text;
        }
        else
        {
            //母批直接分批的时候改为分批长度取剩余长度 modify by lei.xue on 2017-8-19
            //SplitLength = txtPreLength.Text;
            SplitLength = txtRestLength.Text;
        }
        LotBasisDatalist dl = new LotBasisDatalist();
        DataTable        dt = (DataTable)ViewState["lotDt"];
        dl.flowid          = dt.Rows[0]["flowid"].ToString();
        dl.workshopid      = ddlWorkshop.SelectedValue;
        dl.lottype         = "Film";
        dl.status          = "Active";
        dl.createuser      = System.Web.HttpContext.Current.Request.Cookies["userID"].Value.ToString();
        dl.currentflowidno = (Convert.ToInt32(dt.Rows[0]["flowidno"].ToString()) + 1).ToString(); //流程编号加1
        dl.factoryid       = "";
        dl.workorder       = ViewState["WO"].ToString();
        dl.reworkorder     = "";
        dl.lotid           = txtLabelInfo.Text;
        dl.lotcount        = dt.Rows[0]["lotcount"].ToString();
        dl.ProcessComplete = "N";
        dl.UVCompleteLotid = txtLot.Text;
        dl.length          = SplitLength;    //txtSplitLength.Text;
        //================剩余长度和宽度为母批的有效长度和宽度modify by lei.xue on 2017-6-1=============
        dl.restlength = txtValidLength.Text; //SplitLength;//txtSplitLength.Text;
        dl.width      = txtPreWidth.Text;
        dl.restwidth  = txtValidWidth.Text;  //txtPreWidth.Text;
        dl.Filmlevel  = "A";
        //增加贴膜设备编号 add by lei.xue on 2017-2-22
        dl.eqpid = ddlEqp.SelectedValue;
        //增加有效幅宽 add by lei.xue on 2017-4-19
        dl.validwidth = txtValidWidth.Text;
        //增加有效长度 add by lei.xue on 2017-6-11
        dl.validlength = txtValidLength.Text;
        string result = CreateMouldLot.InsertLot(dl);
        if (result != "success")
        {
            JScript.Alert(result, this);
            return;
        }

        //插入分批记录到分批表
        dl.sublotid = txtLabelInfo.Text;
        dl.lotid    = txtLot.Text;
        string resultsplit = PasteFilm.InsertSplitLot(dl);

        //更新母批剩余数量
        Decimal rest    = Convert.ToDecimal(txtRestLength.Text) - Convert.ToDecimal(SplitLength);//txtSplitLength.Text );
        string  strRest = PasteFilm.UpdateParentQty(ViewState["originalLot"].ToString(), rest.ToString(), "Length");
        if (strRest != "success")
        {
            JScript.Alert("更新母批剩余数量失败!", this);
            return;
        }

        if (result != "success" || resultsplit != "success")
        {
            JScript.Alert("创建贴膜条码失败!", this);
            return;
        }

        //子批过站记录 add by lei.xue on 2017-4-26=========================================
        string strWipinfo = PasteFilm.FilmCheckOut(txtLabelInfo.Text, ddlEqp.SelectedValue, ddlWorkshop.SelectedValue, lblWorksiteID.Text, System.Web.HttpContext.Current.Request.Cookies["userID"].Value.ToString());
        if (strWipinfo == "fail")
        {
            JScript.Alert("子批过站记录失败!", this);
            return;
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>PrintLabel('" + txtLabelInfo.Text + "','../Product/PasteFilm.aspx','" + txtProductType.Text + "');</script>");
        //JScript.Alert("创建贴膜条码成功!", this);
    }