/// <summary>
        ///
        /// </summary>
        /// <param name="order">合同信息</param>
        /// <param name="matrl">成品物料信息</param>
        /// <param name="item">组批信息</param>
        /// <param name="ssBmid">部门ID</param>
        /// <returns></returns>
        private NcRollA1 GetA1(Mod_TMO_ORDER order, Mod_TB_MATRL_MAIN matrl, Mod_TRC_ROLL_WW_MAIN item, Mod_TB_STA tBSta, Mod_TS_USER user)
        {
            var ncRollA1 = new NcRollA1
            {
                bmid       = tBSta.C_SSBMID,                      //部门ID
                jhrq       = item.D_MOD_DT,                       //计划日期
                jhxxsl     = (item.N_WGT_TOTAL ?? 0).ToString(),  //下限数量
                jhyid      = matrl.C_PLANEMP,                     // 计划员ID
                jldwid     = matrl.C_PK_MEASDOC,                  //计量单位
                memo       = item.C_REMARK,                       //备注
                pk_produce = matrl.C_PK_PRODUCE,                  //物料PK,
                scbmid     = tBSta.C_SSBMID,                      //生产部门ID
                shrid      = item.C_PRODUCE_EMP_ID,               //操作员
                shrq       = DateTime.Now,                        //审核日期
                slrq       = order.D_DT ?? DateTime.Now,          //需求日期
                wlbmid     = matrl.C_PK_INVBASDOC,                // 存货档案主键
                xdrq       = item.D_MOD_DT,                       //下单日期
                xqrq       = order.D_DELIVERY_DT ?? DateTime.Now, //交货日期
                xqsl       = (item.N_WGT_TOTAL ?? 0).ToString(),  //计划量
                zdrq       = DateTime.Now,                        //制单日期
                zyx1       = order.C_FREE1,                       //自由项1
                zyx2       = order.C_FREE2,                       //自由项2
                zyx3       = order.C_PACK,                        //包装要求
                zyx5       = item.C_ID,                           //PCI主键
            };

            return(ncRollA1);
        }
Esempio n. 2
0
        private void btn_A1_Click(object sender, EventArgs e)
        {
            int selectedPlanHandle = this.gv_TBKPSJ.FocusedRowHandle; //获取计划焦点行索引
            int selectedAllowGrd   = this.gv_TBKPSJ.FocusedRowHandle; //获取可轧钢种焦点行索引

            if (selectedPlanHandle < 0 || selectedAllowGrd < 0)
            {
                MessageBox.Show("请检查计划和可轧钢种,记录为空!");
                return;
            }

            string   id    = this.gv_TBKPSJ.GetRowCellValue(selectedPlanHandle, "C_COGDOWN_ID").ToString();//获取焦点id
            var      model = bll_TRC_COGDOWN_MAIN.GetModel(id);
            NcRollA1 ncA1  = new NcRollA1();
            var      plan  = bll_TRP_PLAN_COGDOWN.GetModel(model.C_PLAN_ID);
            var      a1Sta = bll_TB_STA.GetModel(plan.C_STA_ID);

            ncA1.bmid   = "1001NC1000000000038P";
            ncA1.jhrq   = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
            ncA1.jhxxsl = plan.N_WGT.ToString();
            var matrl = bll_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);

            ncA1.jhyid      = matrl.C_PLANEMP;
            ncA1.jldwid     = matrl.C_PK_MEASDOC;
            ncA1.pk_produce = matrl.C_PK_PRODUCE;
            ncA1.scbmid     = a1Sta.C_SSBMID;
            ncA1.shrid      = RV.UI.UserInfo.userID;
            ncA1.shrq       = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
            ncA1.slrq       = DateTime.Parse(plan.D_NEED_DT == null ? DateTime.Now.ToString() : plan.D_NEED_DT.ToString());
            ncA1.wlbmid     = matrl.C_PK_INVBASDOC;
            ncA1.xdrq       = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
            ncA1.xqrq       = DateTime.Parse(plan.D_DELIVERY_DT == null ? DateTime.Now.ToString() : plan.D_DELIVERY_DT.ToString());
            ncA1.xqsl       = plan.N_WGT.ToString();
            ncA1.zdrq       = DateTime.Now;
            ncA1.zyx1       = plan.C_FREE1;
            ncA1.zyx2       = plan.C_FREE2;
            ncA1.zyx3       = plan.C_PACK;
            ncA1.zyx5       = plan.C_ID;
            string a1Name    = plan.C_ID + "_A1.xml";
            var    arrReault = bll_Interface_NC_Roll_A1.SendXml_ROLL_A1("", a1Name, ncA1, Application.StartupPath);

            if (arrReault[0] != "1")
            {
                bll_TRC_COGDOWN_MAIN.UpdateIfStatus(2, model.C_BATCH_NO, arrReault[1]);
            }
        }
Esempio n. 3
0
        private void btn_A3_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("确认同步吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1))
            {
                return;
            }

            NcRollA2 ncA2 = new NcRollA2();
            NcRollA3 ncA3 = new NcRollA3();
            NcRollA4 ncA4 = new NcRollA4();
            NcRollA1 ncA1 = new NcRollA1();

            try
            {
                int selectedPlanHandle = this.gv_NC.FocusedRowHandle; //获取计划焦点行索引
                int selectedAllowGrd   = this.gv_NC.FocusedRowHandle; //获取可轧钢种焦点行索引
                if (selectedPlanHandle < 0 || selectedAllowGrd < 0)
                {
                    MessageBox.Show("请检查计划和可轧钢种,记录为空!");
                    return;
                }
                string id      = this.gv_NC.GetRowCellValue(selectedPlanHandle, "C_COGDOWN_ID").ToString();//获取焦点
                var    main    = bll_TRC_COGDOWN_MAIN.GetModel(id);
                var    plan    = bll_TRP_PLAN_COGDOWN.GetModel(main.C_PLAN_ID);
                var    matrl   = bll_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);
                var    matrl2  = bll_TB_MATRL_MAIN.GetModel(main.C_MAT_SLAB_CODE);
                var    product = bll_TRC_COGDOWN_PRODUCT.GetModelByCOGID(id);
                var    a2Sta   = bll_TB_STA.GetModel(main.C_STA_ID);
                #region A3
                //int status = 3;
                ncA3.hpch            = main.C_BATCH_NO;
                ncA3.hzdrid          = bll_TRC_COGDOWN_MAIN.GetUser();
                ncA3.hwlbmid         = matrl.C_PK_INVBASDOC;
                ncA3.hjldwid         = matrl.C_PK_MEASDOC;
                ncA3.hzdrq           = DateTime.Parse(product.D_QR_DATE == null ? DateTime.Now.ToString() : product.D_QR_DATE.ToString());
                ncA3.hfreeitemvalue1 = plan.C_FREE1;
                ncA3.hfreeitemvalue2 = plan.C_FREE2;
                ncA3.hfreeitemvalue3 = plan.C_PACK;

                DataTable a3Dt = bll_TRC_COGDOWN_MAIN_ITEM.GetSlabMainInfoKp(main.C_ID);
                //DataTable a3DtZyx = bll_TB_STD_CONFIG.GetZYX(a3Dt.Rows[0]["C_STL_GRD"].ToString(), a3Dt.Rows[0]["C_STD_CODE"].ToString()).Tables[0];
                //var m = GetMatrlModel(a3Dt.Rows[0]["C_MAT_CODE"].ToString());
                ncA3.kgyid          = bll_TRC_COGDOWN_MAIN.GetUser();
                ncA3.ckckid         = bll_TPB_SLABWH.GetList_id(a3Dt.Rows[0]["C_SLABWH_CODE"].ToString()).ToString();
                ncA3.wlbmid         = matrl2.C_PK_INVBASDOC;
                ncA3.jldwid         = matrl2.C_PK_MEASDOC;
                ncA3.fjldwid        = matrl2.C_FJLDW;
                ncA3.ljcksl         = a3Dt.Rows[0]["N_WGT"].ToString();
                ncA3.fljcksl        = a3Dt.Rows[0]["N_QUA"].ToString();
                ncA3.pch            = a3Dt.Rows[0]["C_STOVE"].ToString();
                ncA3.gzzxid         = a2Sta.C_ERP_PK;
                ncA3.freeitemvalue1 = a3Dt.Rows[0]["C_ZYX1"].ToString();
                ncA3.freeitemvalue2 = a3Dt.Rows[0]["C_ZYX2"].ToString();
                object objOutTime = bll_TRC_COGDOWN_MAIN.GetOutTimeKp(main.C_ID);
                ncA3.flrq = product.D_QR_DATE == null?DateTime.Now.ToString() : product.D_QR_DATE.Value.ToString("yyyy-MM-dd");

                string a3Name = Guid.NewGuid() + "_A3.xml";
                if (bll_TRC_COGDOWN_MAIN.IsA3Repeat(main.C_BATCH_NO, "") > 0)
                {
                }
                var resultA3 = bll_Interface_NC_Roll_A3.SendXml_ROLL_A3("", a3Name, ncA3, Application.StartupPath);
                if (resultA3[0] != "1")
                {
                    bll_TRC_COGDOWN_MAIN.UpdateIfStatusCogDown(3, product.C_BATCH_NO, resultA3[1]);
                    bll_TRC_COGDOWN_MAIN.InsertLog(main.C_BATCH_NO, string.Format("计划物料编码:{0},消耗物料编码:{1}", matrl.C_ID, matrl2.C_ID));
                    MessageBox.Show("同步失败");
                    return;
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("同步异常" + ex.ToString());
            }

            Bind();
        }
Esempio n. 4
0
        private void btn_SyncNC_Click(object sender, EventArgs e)
        {
            NcRollA1 ncA1        = new NcRollA1();
            NcRollA2 ncA2        = new NcRollA2();
            NcRollA3 ncA3        = new NcRollA3();
            NcRollA4 ncA4        = new NcRollA4();
            int      result      = 0;
            int      errorStatus = 1;
            string   errorId     = "";

            string strMenuName = RV.UI.UserInfo.menuName;

            UserLog.AddLog(strMenuName, slbwhCode + "同步NC", "同步NC", "同步NC");//添加操作日志

            try
            {
                WaitingFrom.ShowWait("");
                if (dtNC != null && dtNC.Rows.Count > 0)
                {
                    for (int i = 0; i < dtNC.Rows.Count; i++)
                    {
                        string id = dtNC.Rows[i]["C_MAIN_ID"].ToString();
                        errorId = id;
                        var wgd  = bll_TRC_ROLL_WGD.GetModel(id, 1);
                        var plan = bllPlanRollItem.GetModel_Item(wgd.C_PLAN_ID);
                        if (plan.N_IS_MERGE == 1)
                        {
                            continue;
                        }
                        var a1Sta = bll_TB_STA.GetModel(plan.C_STA_ID);
                        ncA1.bmid   = "1001NC10000000000345";
                        ncA1.jhrq   = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
                        ncA1.jhxxsl = plan.N_WGT.ToString();
                        var matrl = bll_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);
                        ncA1.jhyid      = matrl.C_PLANEMP;
                        ncA1.jldwid     = matrl.C_PK_MEASDOC;
                        ncA1.pk_produce = matrl.C_PK_PRODUCE;
                        ncA1.scbmid     = a1Sta.C_SSBMID;
                        ncA1.shrid      = "1006AA100000000ERS2A";//plan.C_EMP_ID;
                        ncA1.shrq       = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
                        ncA1.slrq       = DateTime.Parse(plan.D_NEED_DT == null ? DateTime.Now.ToString() : plan.D_NEED_DT.ToString());
                        ncA1.wlbmid     = matrl.C_PK_INVBASDOC;
                        ncA1.xdrq       = DateTime.Parse(plan.D_P_START_TIME == null ? DateTime.Now.ToString() : plan.D_P_START_TIME.ToString());
                        ncA1.xqrq       = DateTime.Parse(plan.D_DELIVERY_DT == null ? DateTime.Now.ToString() : plan.D_DELIVERY_DT.ToString());
                        ncA1.xqsl       = plan.N_WGT.ToString();
                        ncA1.zdrq       = DateTime.Now;
                        ncA1.zyx1       = plan.C_FREE_TERM;
                        ncA1.zyx2       = plan.C_FREE_TERM2;
                        ncA1.zyx3       = plan.C_PACK;
                        ncA1.zyx5       = plan.C_ID;
                        ncA1.memo       = plan.C_AREA;
                        ncA1.jhfaid     = matrl.C_PK_PSID;
                        string a1Name   = plan.C_ID + "_A1.xml";
                        var    resultA1 = bll_Interface_NC_Roll_A1.SendXml_ROLL_A1("", a1Name, ncA1, Application.StartupPath);
                        if (resultA1[0] != "1")
                        {
                            bll_TRC_ROLL_WGD.UpdateIfStatus(1, id, resultA1[1]);
                            //continue;
                        }

                        DataTable factDt2 = bll_TRC_ROLL_WGD.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                        bool      bol     = false;
                        for (int j = 0; j < factDt2.Rows.Count; j++)
                        {
                            string slabWh = bll_TPB_LINEWH.GetList_id(factDt2.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                            if (string.IsNullOrEmpty(slabWh))
                            {
                                bol = true;
                                break;
                            }
                        }

                        if (bol)
                        {
                            continue;
                        }

                        errorStatus = 2;
                        var main   = bll_TRC_ROLL_MAIN.GetModel(id);
                        var a2Sta  = bll_TB_STA.GetModel(main.C_STA_ID);
                        var matrl2 = bll_TB_MATRL_MAIN.GetModel(main.C_MAT_SLAB_CODE);
                        ncA2.wlbmid         = matrl.C_PK_INVBASDOC;
                        ncA2.pk_produce     = matrl.C_PK_PRODUCE;
                        ncA2.invcode        = matrl.C_ID;
                        ncA2.pch            = main.C_BATCH_NO;
                        ncA2.scbmid         = a2Sta.C_SSBMID;
                        ncA2.gzzxid         = a2Sta.C_ERP_PK;
                        ncA2.bcid           = wgd.C_PRODUCE_SHIFT;
                        ncA2.bzid           = wgd.C_PRODUCE_GROUP;
                        ncA2.jhkgrq         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA2.jhwgrq         = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                        ncA2.jhkssj         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA2.jhjssj         = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                        ncA2.sjkgrq         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA2.sjwgrq         = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                        ncA2.sjkssj         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA2.sjjssj         = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                        ncA2.jhwgsl         = main.N_WGT_EXIT == 0 ? main.N_WGT_ELIM.ToString() : main.N_WGT_EXIT.ToString();
                        ncA2.fjhsl          = main.N_QUA_EXIT == 0 ? main.N_QUA_ELIM.ToString() : main.N_QUA_EXIT.ToString();
                        ncA2.jldwid         = matrl.C_PK_MEASDOC;
                        ncA2.fjlid          = matrl.C_FJLDW;
                        ncA2.sjwgsl         = (main.N_WGT_TOTAL_VIRTUAL - main.N_WGT_TOTAL).ToString();
                        ncA2.freeitemvalue1 = plan.C_FREE_TERM;
                        ncA2.freeitemvalue2 = plan.C_FREE_TERM2;
                        ncA2.freeitemvalue3 = plan.C_PACK;
                        ncA2.zdrid          = RV.UI.UserInfo.userAccount;
                        ncA2.freeitemvalue5 = plan.C_ID;
                        string a2Name = Guid.NewGuid() + "_A2.xml";
                        if (bll_TRC_ROLL_WGD.IsA2Repeat(main.C_BATCH_NO, "") > 0)
                        {
                        }
                        var resultA2 = bll_Interface_NC_Roll_A2.SendXml_ROLL_A2("", a2Name, ncA2, Application.StartupPath);
                        if (resultA2[0] != "1")
                        {
                            bll_TRC_ROLL_WGD.UpdateIfStatus(2, id, resultA2[1]);
                        }

                        if (main.N_WGT_EXIT == 0)
                        {
                            if (bll_TRC_ROLL_WGD.UpdateUpLoadStatus(3, id) > 0)
                            {
                                MessageBox.Show("同步成功");
                            }
                        }

                        errorStatus          = 3;
                        ncA3.hpch            = main.C_BATCH_NO;
                        ncA3.hzdrid          = RV.UI.UserInfo.userAccount;
                        ncA3.hwlbmid         = matrl.C_PK_INVBASDOC;
                        ncA3.hjldwid         = matrl.C_PK_MEASDOC;
                        ncA3.hzdrq           = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                        ncA3.hfreeitemvalue1 = plan.C_FREE_TERM;
                        ncA3.hfreeitemvalue2 = plan.C_FREE_TERM2;
                        ncA3.hfreeitemvalue3 = plan.C_PACK;

                        DataTable consumeDt = new DataTable();
                        DataTable a3Dt      = bll_TRC_WARM_FURNACE.GetSlabMainInfo(wgd.C_MAIN_ID, out consumeDt);
                        DataTable a3DtZyx   = bll_TB_STD_CONFIG.GetZYX(a3Dt.Rows[0]["C_STL_GRD"].ToString(), a3Dt.Rows[0]["C_STD_CODE"].ToString()).Tables[0];
                        var       m         = bll_TB_MATRL_MAIN.GetModel(a3Dt.Rows[0]["C_MAT_CODE"].ToString());
                        ncA3.kgyid          = RV.UI.UserInfo.userAccount;
                        ncA3.ckckid         = bll_TPB_SLABWH.GetList_id(slbwhCode);
                        ncA3.wlbmid         = matrl2.C_PK_INVBASDOC;
                        ncA3.jldwid         = matrl2.C_PK_MEASDOC;
                        ncA3.fjldwid        = matrl2.C_FJLDW;
                        ncA3.ljcksl         = a3Dt.Rows[0]["N_WGT"].ToString();
                        ncA3.fljcksl        = a3Dt.Rows[0]["N_QUA"].ToString();
                        ncA3.pch            = a3Dt.Rows[0]["C_BATCH_NO"].ToString() == "" ? a3Dt.Rows[0]["C_STOVE"].ToString() : a3Dt.Rows[0]["C_BATCH_NO"].ToString();
                        ncA3.gzzxid         = a2Sta.C_ERP_PK;
                        ncA3.freeitemvalue1 = a3Dt.Rows[0]["C_ZYX1"].ToString();
                        ncA3.freeitemvalue2 = a3Dt.Rows[0]["C_ZYX2"].ToString();
                        object objOutTime = bll_TRC_WARM_FURNACE.GetOutTime(main.C_ID);
                        ncA3.flrq = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString()).ToString("yyyy-MM-dd");
                        string a3Name = Guid.NewGuid() + "_A3.xml";
                        if (bll_TRC_ROLL_WGD.IsA3Repeat(main.C_BATCH_NO, "") > 0)
                        {
                        }
                        var resultA3 = bll_Interface_NC_Roll_A3.SendXml_ROLL_A3("", a3Name, ncA3, Application.StartupPath);
                        if (resultA3[0] != "1")
                        {
                            bll_TRC_ROLL_WGD.UpdateIfStatus(3, id, resultA3[1]);
                        }
                        bll_TRC_WARM_FURNACE.ConsumeSlab(consumeDt);

                        errorStatus = 4;
                        DataTable a4FactDt = bll_TRC_ROLL_WGD.GetWgdFact(wgd.C_BATCH_NO, 1).Tables[0];
                        var       a4M      = bll_TB_MATRL_MAIN.GetModel(wgd.C_MAT_CODE);
                        var       a4Sta    = bll_TB_STA.GetModel(wgd.C_STA_ID);
                        ncA4.zdrid      = RV.UI.UserInfo.userAccount;
                        ncA4.rq         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA4.gzzxbmid   = a4Sta.C_STA_ERPCODE;
                        ncA4.scbmid     = a4Sta.C_SSBMID;
                        ncA4.pch        = wgd.C_BATCH_NO;
                        ncA4.wlbmid     = a4M.C_PK_INVBASDOC;
                        ncA4.jldwid     = a4M.C_PK_MEASDOC;
                        ncA4.gzzxid     = a4Sta.C_ERP_PK;
                        ncA4.ccxh       = wgd.C_BATCH_NO;
                        ncA4.pk_produce = a4M.C_PK_PRODUCE;
                        ncA4.ksrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                        ncA4.jsrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                        ncA4.hgsl       = a4FactDt.Rows[0]["WGT"].ToString();
                        ncA4.fhgsl      = a4FactDt.Rows[0]["QUA"].ToString();
                        object wgdHandlerStatus = bll_TRC_ROLL_WGD_HANDLER.GetWgdHandlerStatus(wgd.C_ID);
                        if (wgdHandlerStatus != null)
                        {
                            string status = wgdHandlerStatus.ToString();
                            ncA4.sflfcp = int.Parse(status) == 2 ? "Y" : "N";
                            ncA4.sffsgp = int.Parse(status) == 2 ? "Y" : "N";
                        }
                        else
                        {
                            ncA4.sflfcp = "N";
                            ncA4.sffsgp = "N";
                        }
                        ncA4.freeitemvalue1 = wgd.C_FREE_TERM;
                        ncA4.freeitemvalue2 = wgd.C_FREE_TERM2;
                        ncA4.freeitemvalue3 = wgd.C_PACK;
                        string a4Name = Guid.NewGuid() + "_A4.xml";
                        if (bll_TRC_ROLL_WGD.IsA4Repeat(main.C_BATCH_NO, "") > 0)
                        {
                        }
                        var resultA4 = bll_Interface_NC_Roll_A4.SendXml_ROLL_A4("", a4Name, ncA4, Application.StartupPath);
                        if (resultA4[0] != "1")
                        {
                            bll_TRC_ROLL_WGD.UpdateIfStatus(4, id, resultA4[1]);
                        }

                        errorStatus = 5;
                        decimal         wgdWgt = 0;
                        DataTable       factDt = bll_TRC_ROLL_WGD.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                        List <NcRoll46> nc46s  = new List <NcRoll46>();
                        for (int j = 0; j < factDt.Rows.Count; j++)
                        {
                            NcRoll46 nc46 = new NcRoll46();
                            var      a46M = bll_TB_MATRL_MAIN.GetModel(factDt.Rows[j]["C_MAT_CODE"].ToString());
                            nc46.cwarehouseid = bll_TPB_LINEWH.GetList_id(factDt.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                            nc46.taccounttime = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                            nc46.coperatorid  = RV.UI.UserInfo.userAccount;
                            //if (wgd.C_MRSX == "DP")
                            //{ }
                            nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName("DP", "1001").C_ID;
                            //else
                            //    nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName(factDt.Rows[j]["C_JUDGE_LEV_BP"].ToString(), "1001").C_ID;
                            nc46.cworkcenterid = bll_TB_STA.Get_NC_ID(wgd.C_STA_ID);
                            nc46.dbizdate      = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                            nc46.vbatchcode    = wgd.C_BATCH_NO;
                            nc46.cinvbasid     = a46M.C_PK_INVBASDOC;
                            nc46.pk_produce    = a46M.C_PK_PRODUCE;
                            nc46.ninnum        = factDt.Rows[j]["WGT"].ToString();
                            nc46.ninassistnum  = factDt.Rows[j]["QUA"].ToString();
                            nc46.castunitid    = a46M.C_FJLDW;
                            nc46.vfree1        = factDt.Rows[j]["C_ZYX1"].ToString();
                            nc46.vfree2        = factDt.Rows[j]["C_ZYX2"].ToString();
                            nc46.vfree3        = factDt.Rows[j]["C_BZYQ"].ToString();
                            nc46s.Add(nc46);
                            wgdWgt += decimal.Parse(factDt.Rows[j]["WGT"].ToString());
                        }

                        string a46Name = Guid.NewGuid() + "_A46.xml";

                        var resultA46 = bll_Interface_NC_Roll_46.SendXml_ROLL_46("", a46Name, nc46s, Application.StartupPath);
                        if (resultA46[0] != "1")
                        {
                            bll_TRC_ROLL_WGD.UpdateIfStatus(5, id, resultA46[1]);
                        }

                        if (bll_TRC_ROLL_WGD.Is46Repeat(main.C_BATCH_NO, "") > 0)
                        {
                            bll_TRC_ROLL_WGD.UpdateRollPlanItemWgt(plan.C_ID, wgdWgt);

                            if (bll_TRC_ROLL_WGD.UpdateUpLoadStatus(3, id) > 0)
                            {
                                result++;
                            }
                        }
                    }
                }
                WaitingFrom.CloseWait();
                MessageBox.Show("同步成功" + result);
            }
            catch (Exception ex)
            {
                bll_TRC_ROLL_WGD.UpdateIfStatus(errorStatus, errorId, ex.Message);
                MessageBox.Show("同步错误");
            }
            BindWgd();
        }
Esempio n. 5
0
        /// <summary>
        /// 删除线材
        /// </summary>
        /// <param name="ids">主键</param>
        /// <returns></returns>
        public int DelRollProduct(List <string> ids, string batchNo, string path)
        {
            TransactionHelper.BeginTransaction();
            decimal bWgt   = dal.GetRollProductWgt(batchNo);
            string  id     = dal.GetRollMain(batchNo);
            string  planId = "";

            if (dal.DelRollProduct(ids) <= 0)
            {
                TransactionHelper.RollBack();
                return(0);
            }

            NcRollA1 ncA1        = new NcRollA1();
            NcRollA2 ncA2        = new NcRollA2();
            NcRollA3 ncA3        = new NcRollA3();
            NcRollA4 ncA4        = new NcRollA4();
            int      errorStatus = 4;
            string   errorId     = "";

            try
            {
                errorId = id;
                var wgd  = dal.GetModel(id, 1);
                var plan = planDalItem.GetModel_Item(wgd.C_PLAN_ID);
                planId = wgd.C_PLAN_ID;
                var a1Sta = dal_TB_STA.GetModel(plan.C_STA_ID);
                var matrl = dal_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);
                var main  = dal_TRC_ROLL_MAIN.GetModel(id);
                var a2Sta = dal_TB_STA.GetModel(main.C_STA_ID);

                //DataTable factDt2 = dal.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                //for (int j = 0; j < factDt2.Rows.Count; j++)
                //{
                //    string slabWh = dal_TPB_LINEWH.GetList_id(factDt2.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                //    if (string.IsNullOrEmpty(slabWh))
                //    {
                //        return 0;
                //    }
                //}

                DataTable a4FactDt = dal.GetWgdFactTran(wgd.C_BATCH_NO, 1, ids).Tables[0];
                var       a4M      = dal_TB_MATRL_MAIN.GetModel(wgd.C_MAT_CODE);
                var       a4Sta    = dal_TB_STA.GetModel(wgd.C_STA_ID);
                ncA4.zdrid      = RV.UI.UserInfo.userAccount;
                ncA4.rq         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                ncA4.gzzxbmid   = a4Sta.C_STA_ERPCODE;
                ncA4.scbmid     = a4Sta.C_SSBMID;
                ncA4.pch        = wgd.C_BATCH_NO;
                ncA4.wlbmid     = a4M.C_PK_INVBASDOC;
                ncA4.jldwid     = a4M.C_PK_MEASDOC;
                ncA4.gzzxid     = a4Sta.C_ERP_PK;
                ncA4.ccxh       = wgd.C_BATCH_NO;
                ncA4.pk_produce = a4M.C_PK_PRODUCE;
                ncA4.ksrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                ncA4.jsrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                ncA4.hgsl       = a4FactDt.Rows[0]["WGT"].ToString();
                ncA4.fhgsl      = a4FactDt.Rows[0]["QUA"].ToString();
                object wgdHandlerStatus = wgdHandlerDal.GetWgdHandlerStatus(wgd.C_ID);
                if (wgdHandlerStatus != null)
                {
                    string status = wgdHandlerStatus.ToString();
                    ncA4.sflfcp = int.Parse(status) == 2 ? "Y" : "N";
                    ncA4.sffsgp = int.Parse(status) == 2 ? "Y" : "N";
                }
                else
                {
                    ncA4.sflfcp = "N";
                    ncA4.sffsgp = "N";
                }
                ncA4.freeitemvalue1 = wgd.C_FREE_TERM;
                ncA4.freeitemvalue2 = wgd.C_FREE_TERM2;
                ncA4.freeitemvalue3 = wgd.C_PACK;
                string a4Name = Guid.NewGuid() + "_A4.xml";
                if (dal.IsA4Repeat(main.C_BATCH_NO, "") > 0)
                {
                    TransactionHelper.RollBack();
                    return(0);
                }
                var resultA4 = dal_Interface_NC_Roll_A4.SendXml_ROLL_A4("", a4Name, ncA4, path);
                if (resultA4[0] != "1")
                {
                    dal.UpdateIfStatus(4, id, resultA4[1]);
                    TransactionHelper.RollBack();
                    return(0);
                }

                errorStatus = 5;
                DataTable       factDt = factDt = dal.GetWgdFactAttrDPTran(wgd.C_BATCH_NO, ids).Tables[0];
                List <NcRoll46> nc46s  = new List <NcRoll46>();
                decimal         wgdWgt = 0;
                for (int j = 0; j < factDt.Rows.Count; j++)
                {
                    NcRoll46 nc46 = new NcRoll46();
                    var      a46M = dal_TB_MATRL_MAIN.GetModel(factDt.Rows[j]["C_MAT_CODE"].ToString());
                    nc46.cwarehouseid = dal_TPB_LINEWH.GetList_id(factDt.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                    nc46.taccounttime = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                    nc46.coperatorid  = RV.UI.UserInfo.userAccount;
                    //if (wgd.C_MRSX == "DP")
                    //{ }
                    nc46.ccheckstate_bid = dal_TQB_CHECKSTATE.GetModelByName("DP", "1001").C_ID;
                    //else
                    //    nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName(factDt.Rows[j]["C_JUDGE_LEV_BP"].ToString(), "1001").C_ID;
                    nc46.cworkcenterid = dal_TB_STA.Get_NC_ID(wgd.C_STA_ID);
                    nc46.dbizdate      = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                    nc46.vbatchcode    = wgd.C_BATCH_NO;
                    nc46.cinvbasid     = a46M.C_PK_INVBASDOC;
                    nc46.pk_produce    = a46M.C_PK_PRODUCE;
                    nc46.ninnum        = factDt.Rows[j]["WGT"].ToString();
                    nc46.ninassistnum  = factDt.Rows[j]["QUA"].ToString();
                    nc46.castunitid    = a46M.C_FJLDW;
                    nc46.vfree1        = factDt.Rows[j]["C_ZYX1"].ToString();
                    nc46.vfree2        = factDt.Rows[j]["C_ZYX2"].ToString();
                    nc46.vfree3        = factDt.Rows[j]["C_BZYQ"].ToString();
                    nc46s.Add(nc46);
                    wgdWgt += decimal.Parse(factDt.Rows[j]["WGT"].ToString());
                }
                string a46Name = Guid.NewGuid() + "_A46.xml";
                if (dal.Is46Repeat(main.C_BATCH_NO, "") > 0)
                {
                    TransactionHelper.RollBack();
                    return(0);
                }
                var resultA46 = dal_Interface_NC_Roll_46.SendXml_ROLL_46("", a46Name, nc46s, path);
                if (resultA46[0] != "1")
                {
                    dal.UpdateIfStatus(5, id, resultA46[1]);
                    TransactionHelper.RollBack();
                    return(0);
                }
                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                dal.UpdateIfStatus(errorStatus, errorId, ex.Message);
            }

            decimal eWgt = dal.GetRollProductWgt(batchNo);

            dal.UpdateRollPlanItemWgt(planId, bWgt, 1);
            dal.UpdateRollPlanItemWgt(planId, eWgt);
            return(1);
        }
Esempio n. 6
0
 public List <string> SendXml_ROLL_A1(string dayplcode, string xmlFileName, NcRollA1 nc, string path)
 {
     return(dal.SendXml_ROLL_A1(dayplcode, xmlFileName, nc, path));
 }
Esempio n. 7
0
        private void btn_A3_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("确认同步吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1))
            {
                return;
            }

            NcRollA1 ncA1        = new NcRollA1();
            NcRollA2 ncA2        = new NcRollA2();
            NcRollA3 ncA3        = new NcRollA3();
            NcRollA4 ncA4        = new NcRollA4();
            int      errorStatus = 3;
            string   errorId     = "";

            try
            {
                int selectedPlanHandle = this.gv_NC.FocusedRowHandle; //获取计划焦点行索引
                int selectedAllowGrd   = this.gv_NC.FocusedRowHandle; //获取可轧钢种焦点行索引
                if (selectedPlanHandle < 0 || selectedAllowGrd < 0)
                {
                    MessageBox.Show("请检查计划和可轧钢种,记录为空!");
                    return;
                }
                string id = this.gv_NC.GetRowCellValue(selectedPlanHandle, "C_MAIN_ID").ToString();//获取焦点
                errorId = id;
                var wgd = bll_TRC_ROLL_WGD.GetModel(id, 1);

                var plan   = bllPlanRollItem.GetModel_Item(wgd.C_PLAN_ID);
                var roll   = bll_TRC_ROLL_MAIN.GetModel(wgd.C_MAIN_ID);
                var a1Sta  = bll_TB_STA.GetModel(plan.C_STA_ID);
                var matrl  = bll_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);
                var matrl2 = bll_TB_MATRL_MAIN.GetModel(roll.C_MAT_SLAB_CODE);
                var main   = bll_TRC_ROLL_MAIN.GetModel(id);
                var a2Sta  = bll_TB_STA.GetModel(main.C_STA_ID);

                DataTable factDt2 = bll_TRC_ROLL_WGD.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                for (int j = 0; j < factDt2.Rows.Count; j++)
                {
                    string slabWh = bll_TPB_LINEWH.GetList_id(factDt2.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                    if (string.IsNullOrEmpty(slabWh))
                    {
                        MessageBox.Show("线材无仓库");
                        return;
                    }
                }

                ncA3.hpch            = main.C_BATCH_NO;
                ncA3.hzdrid          = RV.UI.UserInfo.userAccount;
                ncA3.hwlbmid         = matrl.C_PK_INVBASDOC;
                ncA3.hjldwid         = matrl.C_PK_MEASDOC;
                ncA3.hzdrq           = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                ncA3.hfreeitemvalue1 = plan.C_FREE_TERM;
                ncA3.hfreeitemvalue2 = plan.C_FREE_TERM2;
                ncA3.hfreeitemvalue3 = plan.C_PACK;

                DataTable consumeDt = new DataTable();
                DataTable a3Dt      = bll_TRC_WARM_FURNACE.GetSlabMainInfo(wgd.C_MAIN_ID, out consumeDt);
                DataTable a3DtZyx   = bll_TB_STD_CONFIG.GetZYX(a3Dt.Rows[0]["C_STL_GRD"].ToString(), a3Dt.Rows[0]["C_STD_CODE"].ToString()).Tables[0];

                var m = bll_TB_MATRL_MAIN.GetModel(a3Dt.Rows[0]["C_MAT_CODE"].ToString());
                ncA3.kgyid          = RV.UI.UserInfo.userAccount;
                ncA3.ckckid         = bll_TPB_SLABWH.GetList_id(a3Dt.Rows[0]["c_slabwh_code"].ToString());
                ncA3.wlbmid         = matrl2.C_PK_INVBASDOC;
                ncA3.jldwid         = matrl2.C_PK_MEASDOC;
                ncA3.fjldwid        = matrl2.C_FJLDW;
                ncA3.ljcksl         = a3Dt.Rows[0]["N_WGT"].ToString();
                ncA3.fljcksl        = a3Dt.Rows[0]["N_QUA"].ToString();
                ncA3.pch            = a3Dt.Rows[0]["C_BATCH_NO"].ToString() == "" ? a3Dt.Rows[0]["C_STOVE"].ToString() : a3Dt.Rows[0]["C_BATCH_NO"].ToString();
                ncA3.gzzxid         = a2Sta.C_ERP_PK;
                ncA3.freeitemvalue1 = a3Dt.Rows[0]["C_ZYX1"].ToString();
                ncA3.freeitemvalue2 = a3Dt.Rows[0]["C_ZYX2"].ToString();
                object objOutTime = bll_TRC_WARM_FURNACE.GetOutTime(main.C_ID);
                ncA3.flrq = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString()).ToString("yyyy-MM-dd");
                string a3Name = Guid.NewGuid() + "_A3.xml";
                if (bll_TRC_ROLL_WGD.IsA3Repeat(main.C_BATCH_NO, "") > 0)
                {
                    return;
                }
                var resultA3 = bll_Interface_NC_Roll_A3.SendXml_ROLL_A3("", a3Name, ncA3, Application.StartupPath);
                if (resultA3[0] != "1")
                {
                    bll_TRC_ROLL_WGD.UpdateIfStatus(3, id, resultA3[1]);
                    MessageBox.Show("同步失败");
                    return;
                }
                bll_TRC_WARM_FURNACE.ConsumeSlab(consumeDt);

                if (bll_TRC_ROLL_WGD.UpdateUpLoadStatus(3, id) > 0)
                {
                    MessageBox.Show("同步成功");
                }
            }
            catch (Exception ex)
            {
                bll_TRC_ROLL_WGD.UpdateIfStatus(errorStatus, errorId, ex.Message);
                MessageBox.Show("同步失败");
            }

            Bind();
        }
Esempio n. 8
0
        public List <string> SendXml_ROLL_A1(string dayplcode, string xmlFileName, NcRollA1 nc, string path)
        {
            try
            {
                string url = path + "\\NCXML";
                if (!Directory.Exists(url))
                {
                    Directory.CreateDirectory(url);
                }

                //Bll_TMP_DAYPLAN tmp_dayplan = new Bll_TMP_DAYPLAN();
                //Mod_TMP_DAYPLAN modPlan = tmp_dayplan.GetModel(dayplcode);

                XmlDocument xmlDoc = new XmlDocument();
                //创建类型声明节点
                XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");
                xmlDoc.AppendChild(node);

                //创建根节点
                XmlElement root = xmlDoc.CreateElement("ufinterface");
                #region//给节点属性赋值
                root.SetAttribute("account", "1");
                root.SetAttribute("billtype", "A1");
                root.SetAttribute("filename", "" + dayplcode + ".xml");
                root.SetAttribute("isexchange", "Y");
                root.SetAttribute("proc", "add");
                root.SetAttribute("receiver", "101");
                root.SetAttribute("replace", "Y");
                root.SetAttribute("roottag", "bill");
                root.SetAttribute("sender", "1107");
                #endregion
                xmlDoc.AppendChild(root);

                //创建子根节点
                XmlElement so_order = xmlDoc.CreateElement("bill");
                //#region//节点属性
                //so_order.SetAttribute("id", dayplcode);
                //#endregiond
                root.AppendChild(so_order);

                XmlNode head = xmlDoc.CreateNode(XmlNodeType.Element, "billhead", null);

                #region                                                   //表头_order_head

                CreateNode(xmlDoc, head, "bgbz", "1");                    //变更标志
                CreateNode(xmlDoc, head, "bmid", nc.bmid);                //部门ID  用下发计划人查询部门
                CreateNode(xmlDoc, head, "bmmc", "");                     //部门名称
                CreateNode(xmlDoc, head, "bomver", "");                   //BOM版本
                CreateNode(xmlDoc, head, "busiDate", "");
                CreateNode(xmlDoc, head, "ckbm", "");                     //仓库编码
                CreateNode(xmlDoc, head, "ckbmid", "");                   //仓库编码ID
                CreateNode(xmlDoc, head, "ckmc", "");                     //仓库名称
                CreateNode(xmlDoc, head, "curwwsl", "");
                CreateNode(xmlDoc, head, "ddlx", "1");                    //订单类型
                CreateNode(xmlDoc, head, "ddlxshow", "");
                CreateNode(xmlDoc, head, "durl", "");                     //资料路径
                CreateNode(xmlDoc, head, "fah", "");
                CreateNode(xmlDoc, head, "fjbz", "0");                    //分解标记
                CreateNode(xmlDoc, head, "fjldwid", "");                  //辅计量单位ID
                CreateNode(xmlDoc, head, "fjldwmc", "");
                CreateNode(xmlDoc, head, "gcbm", "1001NC10000000000669"); //工厂
                CreateNode(xmlDoc, head, "gcbmcode", "");
                CreateNode(xmlDoc, head, "graphid", "");
                CreateNode(xmlDoc, head, "gzzxbm", ""); //工作中心编码ID
                CreateNode(xmlDoc, head, "gzzxid", ""); //工作中心ID
                CreateNode(xmlDoc, head, "gzzxmc", ""); //工作中心名称
                CreateNode(xmlDoc, head, "hbbz", "0");  //合并标志
                CreateNode(xmlDoc, head, "hsl", "");    //换算率
                CreateNode(xmlDoc, head, "invspec", "");
                CreateNode(xmlDoc, head, "invtype", "");
                CreateNode(xmlDoc, head, "jhbmbm", "");
                CreateNode(xmlDoc, head, "jhddh", "");                            //计划订单号
                CreateNode(xmlDoc, head, "jhfaid", nc.jhfaid);                    //计划方案ID
                CreateNode(xmlDoc, head, "jhlx", "0");                            //备料计划类型(固定)
                CreateNode(xmlDoc, head, "jhrq", nc.jhrq.ToString("yyyy-MM-dd")); //计划日期
                CreateNode(xmlDoc, head, "jhxxsl", nc.jhxxsl);                    //计划下限数量
                CreateNode(xmlDoc, head, "jhyid", nc.jhyid);                      //计划员ID
                CreateNode(xmlDoc, head, "jldw", "");                             //计量单位
                CreateNode(xmlDoc, head, "jldwid", nc.jldwid);                    //计量单位ID
                CreateNode(xmlDoc, head, "ksid", "");                             //客商ID
                CreateNode(xmlDoc, head, "memo", nc.memo);                        //备注
                CreateNode(xmlDoc, head, "pch", "");                              //批次号
                CreateNode(xmlDoc, head, "pk_corp", "1001");                      //公司
                CreateNode(xmlDoc, head, "pk_poid", "");                          //计划订单主键
                CreateNode(xmlDoc, head, "pk_produce", nc.pk_produce);            //物料PK
                CreateNode(xmlDoc, head, "primaryKey", "");
                CreateNode(xmlDoc, head, "pzh", "");                              //配置号
                CreateNode(xmlDoc, head, "qrrid", "");
                CreateNode(xmlDoc, head, "qrrq", "");
                CreateNode(xmlDoc, head, "rtver", "");
                CreateNode(xmlDoc, head, "scbmbm", "");
                CreateNode(xmlDoc, head, "scbmid", nc.scbmid);//生产部门ID
                CreateNode(xmlDoc, head, "scbmmc", "");
                CreateNode(xmlDoc, head, "scbz", "1");
                CreateNode(xmlDoc, head, "scxid", "");
                CreateNode(xmlDoc, head, "shrid", nc.shrid);
                CreateNode(xmlDoc, head, "shrq", nc.shrq.ToString("yyyy-MM-dd"));
                CreateNode(xmlDoc, head, "slrq", nc.slrq.ToString("yyyy-MM-dd"));
                CreateNode(xmlDoc, head, "unitcode", "");
                CreateNode(xmlDoc, head, "userid", "");
                CreateNode(xmlDoc, head, "wlbm", "");
                CreateNode(xmlDoc, head, "wlbmid", nc.wlbmid);
                CreateNode(xmlDoc, head, "wlmc", "");
                CreateNode(xmlDoc, head, "wpcsl", "0.00000000");
                CreateNode(xmlDoc, head, "wwlx", "OA");
                CreateNode(xmlDoc, head, "xdrq", nc.xdrq.ToString("yyyy-MM-dd"));
                CreateNode(xmlDoc, head, "xqfsl", "");
                CreateNode(xmlDoc, head, "xqrq", nc.xqrq.ToString("yyyy-MM-dd"));
                CreateNode(xmlDoc, head, "xqsl", nc.xqsl);
                CreateNode(xmlDoc, head, "xsddh", "");
                CreateNode(xmlDoc, head, "xsddid", "");
                CreateNode(xmlDoc, head, "xxbz", "0");
                CreateNode(xmlDoc, head, "yfjsl", "");
                CreateNode(xmlDoc, head, "ypcsl", "");
                CreateNode(xmlDoc, head, "ywwsl", "");
                CreateNode(xmlDoc, head, "zdrid", nc.shrid);
                CreateNode(xmlDoc, head, "zdrmc", "");
                CreateNode(xmlDoc, head, "zdrq", nc.zdrq.ToString("yyyy-MM-dd"));
                CreateNode(xmlDoc, head, "zdy1", "");
                CreateNode(xmlDoc, head, "zdy2", "其它要求");
                CreateNode(xmlDoc, head, "zdy3", "");
                CreateNode(xmlDoc, head, "zdy4", "火运");
                CreateNode(xmlDoc, head, "zdy5", "特级");
                CreateNode(xmlDoc, head, "zt", "B");
                CreateNode(xmlDoc, head, "zyx1", nc.zyx1);
                CreateNode(xmlDoc, head, "zyx2", nc.zyx2);
                CreateNode(xmlDoc, head, "zyx3", nc.zyx3);
                CreateNode(xmlDoc, head, "zyx4", "");
                CreateNode(xmlDoc, head, "zyx5", nc.zyx5);//pci主键
                #endregion

                so_order.AppendChild(head);
                xmlDoc.Save(url + "\\" + xmlFileName);
                var             result = dalSendNC.SendXML(url + "\\" + xmlFileName);
                Mod_TB_NCIF_LOG log    = new Mod_TB_NCIF_LOG();
                log.C_TYPE            = "A1";
                log.C_RESULT          = result[0];
                log.C_REMARK          = result[1];
                log.C_RELATIONSHIP_ID = nc.zyx5;
                dal_TB_NCIF_LOG.Add(log);
                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 9
0
        private void btn_A4_Click(object sender, EventArgs e)
        {
            NcRollA1 ncA1        = new NcRollA1();
            NcRollA2 ncA2        = new NcRollA2();
            NcRollA3 ncA3        = new NcRollA3();
            NcRollA4 ncA4        = new NcRollA4();
            int      errorStatus = 4;
            string   errorId     = "";


            try
            {
                int selectedPlanHandle = this.gv_NC.FocusedRowHandle; //获取计划焦点行索引
                int selectedAllowGrd   = this.gv_NC.FocusedRowHandle; //获取可轧钢种焦点行索引
                if (selectedPlanHandle < 0 || selectedAllowGrd < 0)
                {
                    MessageBox.Show("请检查计划和可轧钢种,记录为空!");
                    return;
                }
                string id = this.gv_NC.GetRowCellValue(selectedPlanHandle, "C_MAIN_ID").ToString();//获取焦点
                errorId = id;
                var wgd   = bll_TRC_ROLL_WGD.GetModel(id, 1);
                var plan  = bllPlanRollItem.GetModel_Item(wgd.C_PLAN_ID);
                var a1Sta = bll_TB_STA.GetModel(plan.C_STA_ID);
                var matrl = bll_TB_MATRL_MAIN.GetModel(plan.C_MAT_CODE);
                var main  = bll_TRC_ROLL_MAIN.GetModel(id);
                var a2Sta = bll_TB_STA.GetModel(main.C_STA_ID);

                DataTable factDt2 = bll_TRC_ROLL_WGD.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                for (int j = 0; j < factDt2.Rows.Count; j++)
                {
                    string slabWh = bll_TPB_LINEWH.GetList_id(factDt2.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                    if (string.IsNullOrEmpty(slabWh))
                    {
                        MessageBox.Show("线材无仓库");
                        return;
                    }
                }

                DataTable a4FactDt = bll_TRC_ROLL_WGD.GetWgdFact(wgd.C_BATCH_NO, 1).Tables[0];
                var       a4M      = bll_TB_MATRL_MAIN.GetModel(wgd.C_MAT_CODE);
                var       a4Sta    = bll_TB_STA.GetModel(wgd.C_STA_ID);
                ncA4.zdrid      = RV.UI.UserInfo.userAccount;
                ncA4.rq         = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                ncA4.gzzxbmid   = a4Sta.C_STA_ERPCODE;
                ncA4.scbmid     = a4Sta.C_SSBMID;
                ncA4.pch        = wgd.C_BATCH_NO;
                ncA4.wlbmid     = a4M.C_PK_INVBASDOC;
                ncA4.jldwid     = a4M.C_PK_MEASDOC;
                ncA4.gzzxid     = a4Sta.C_ERP_PK;
                ncA4.ccxh       = wgd.C_BATCH_NO;
                ncA4.pk_produce = a4M.C_PK_PRODUCE;
                ncA4.ksrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_B == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_B.ToString());
                ncA4.jsrq       = DateTime.Parse(wgd.D_PRODUCE_DATE_E == null ? DateTime.Now.ToString() : wgd.D_PRODUCE_DATE_E.ToString());
                ncA4.hgsl       = a4FactDt.Rows[0]["WGT"].ToString();
                ncA4.fhgsl      = a4FactDt.Rows[0]["QUA"].ToString();
                object wgdHandlerStatus = bll_TRC_ROLL_WGD_HANDLER.GetWgdHandlerStatus(wgd.C_ID);
                if (wgdHandlerStatus != null)
                {
                    string status = wgdHandlerStatus.ToString();
                    ncA4.sflfcp = int.Parse(status) == 2 ? "Y" : "N";
                    ncA4.sffsgp = int.Parse(status) == 2 ? "Y" : "N";
                }
                else
                {
                    ncA4.sflfcp = "N";
                    ncA4.sffsgp = "N";
                }
                ncA4.freeitemvalue1 = wgd.C_FREE_TERM;
                ncA4.freeitemvalue2 = wgd.C_FREE_TERM2;
                ncA4.freeitemvalue3 = wgd.C_PACK;
                string a4Name = Guid.NewGuid() + "_A4.xml";
                if (bll_TRC_ROLL_WGD.IsA4Repeat(main.C_BATCH_NO, "") > 0)
                {
                    return;
                }
                var resultA4 = bll_Interface_NC_Roll_A4.SendXml_ROLL_A4("", a4Name, ncA4, Application.StartupPath);
                if (resultA4[0] != "1")
                {
                    bll_TRC_ROLL_WGD.UpdateIfStatus(4, id, resultA4[1]);
                    MessageBox.Show("同步失败");
                    return;
                }

                errorStatus = 5;
                DataTable       factDt = factDt = bll_TRC_ROLL_WGD.GetWgdFactAttrDP(wgd.C_BATCH_NO).Tables[0];
                List <NcRoll46> nc46s  = new List <NcRoll46>();
                decimal         wgdWgt = 0;
                for (int j = 0; j < factDt.Rows.Count; j++)
                {
                    NcRoll46 nc46 = new NcRoll46();
                    var      a46M = bll_TB_MATRL_MAIN.GetModel(factDt.Rows[j]["C_MAT_CODE"].ToString());
                    nc46.cwarehouseid = bll_TPB_LINEWH.GetList_id(factDt.Rows[j]["C_LINEWH_CODE"].ToString()).ToString();
                    nc46.taccounttime = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                    nc46.coperatorid  = RV.UI.UserInfo.userAccount;
                    //if (wgd.C_MRSX == "DP")
                    //{ }
                    nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName("DP", "1001").C_ID;
                    //else
                    //    nc46.ccheckstate_bid = bll_TQB_CHECKSTATE.GetModelByName(factDt.Rows[j]["C_JUDGE_LEV_BP"].ToString(), "1001").C_ID;
                    nc46.cworkcenterid = bll_TB_STA.Get_NC_ID(wgd.C_STA_ID);
                    nc46.dbizdate      = DateTime.Parse(wgd.D_MOD_DT == null ? DateTime.Now.ToString() : wgd.D_MOD_DT.ToString());
                    nc46.vbatchcode    = wgd.C_BATCH_NO;
                    nc46.cinvbasid     = a46M.C_PK_INVBASDOC;
                    nc46.pk_produce    = a46M.C_PK_PRODUCE;
                    nc46.ninnum        = factDt.Rows[j]["WGT"].ToString();
                    nc46.ninassistnum  = factDt.Rows[j]["QUA"].ToString();
                    nc46.castunitid    = a46M.C_FJLDW;
                    nc46.vfree1        = factDt.Rows[j]["C_ZYX1"].ToString();
                    nc46.vfree2        = factDt.Rows[j]["C_ZYX2"].ToString();
                    nc46.vfree3        = factDt.Rows[j]["C_BZYQ"].ToString();
                    nc46s.Add(nc46);
                    wgdWgt += decimal.Parse(factDt.Rows[j]["WGT"].ToString());
                }
                string a46Name = Guid.NewGuid() + "_A46.xml";
                if (bll_TRC_ROLL_WGD.Is46Repeat(main.C_BATCH_NO, "") > 0)
                {
                    return;
                }
                var resultA46 = bll_Interface_NC_Roll_46.SendXml_ROLL_46("", a46Name, nc46s, Application.StartupPath);
                if (resultA46[0] != "1")
                {
                    bll_TRC_ROLL_WGD.UpdateIfStatus(5, id, resultA46[1]);
                    MessageBox.Show("同步失败");
                    return;
                }

                bll_TRC_ROLL_WGD.UpdateRollPlanItemWgt(plan.C_ID, wgdWgt);

                if (bll_TRC_ROLL_WGD.UpdateUpLoadStatus(3, id) > 0)
                {
                    MessageBox.Show("同步成功");
                }
            }
            catch (Exception ex)
            {
                bll_TRC_ROLL_WGD.UpdateIfStatus(errorStatus, errorId, ex.Message);
                MessageBox.Show("同步失败");
                BindWgd();
            }
            BindWgd();
        }