Exemplo n.º 1
0
        /// <summary>
        /// 修改钢坯状态
        /// </summary>
        /// <param name="list">List<CommonKC>通用库存处理类</param>
        /// <param name="status">状态</param>
        /// <returns>0失败1成功</returns>
        public int UPSLABSTATUS(List <CommonKC> list, string fydh, string status)
        {
            TransactionHelper.BeginTransaction();
            foreach (CommonKC item in list)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("UPDATE TSC_SLAB_MAIN   SET C_MOVE_TYPE='" + status + "',C_FYDH='" + fydh + "' ,C_FYID='" + item.id + "' WHERE C_MOVE_TYPE='E'");
                if (item.mat.Trim() != "")
                {
                    strSql.Append(" and C_MAT_CODE='" + item.mat + "'");
                }
                if (item.ck.Trim() != "")
                {
                    strSql.Append(" and C_SLABWH_CODE='" + item.ck + "'");
                }

                if (item.batch.Trim() != "")
                {
                    strSql.Append(" and C_BATCH_NO='" + item.batch + "'");
                }
                if (item.stove.Trim() != "")
                {
                    strSql.Append(" and C_STOVE='" + item.stove + "'");
                }
                strSql.Append(" and ROWNUM<='" + item.num + "'");
                if (TransactionHelper.ExecuteSql(strSql.ToString()) != item.num)
                {
                    TransactionHelper.RollBack();
                    return(0);
                }
            }
            TransactionHelper.Commit();
            return(1);
        }
Exemplo n.º 2
0
        public void SetFinish(Mod_TRC_ROLL_WW_MAIN model)
        {
            try
            {
                TransactionHelper.BeginTransaction();

                string sql = $"UPDATE TRC_ROLL_WW_MAIN SET N_WGT_REMOVE={model.N_WGT_REMOVE}" +
                             $",N_QUA_REMOVE={model.N_QUA_REMOVE}" +
                             $",N_STATUS={model.N_STATUS}" +
                             $",C_PRODUCE_GROUP='{model.C_PRODUCE_GROUP}'" +
                             $",C_CHECKSTATE_NAME='{model.C_CHECKSTATE_NAME}'" +
                             $",C_LINEWH_CODE='{model.C_LINEWH_CODE}'" +
                             $",C_LINEWH_NAME='{model.C_LINEWH_NAME}'" +
                             $",C_PRODUCE_EMP_ID='{model.C_PRODUCE_EMP_ID}'" +
                             $",C_PRODUCE_SHIFT='{model.C_PRODUCE_SHIFT}' WHERE C_ID='{model.C_ID}'";

                //                // 完工量不等于组批量,回写库存重量
                //                var amt = model.N_WGT_TOTAL - model.N_WGT_REMOVE;
                //                if (amt > 0)
                //                {
                //                    string whereSql = $@"
                //SELECT MAX(C_ID) FROM TRC_ROLL_PRODCUT
                //WHERE C_BATCH_NO='{model.C_XC_BATCH_NO}' AND C_LINEWH_CODE='{model.C_XC_LINEWH_CODE}'
                //AND C_MAT_CODE='{model.C_MAT_XC_CODE}' AND C_BZYQ='{model.C_XC_BZYQ}'
                //AND C_MOVE_TYPE='QE'
                //";
                //                    var cId = TransactionHelper.GetSingle(whereSql)?.ToString();

                //                    if (string.IsNullOrEmpty(cId))
                //                    {
                //                        throw new Exception("找不到记录库存");
                //                    }

                //                    var updateSql = $"UPDATE TRC_ROLL_PRODCUT SET N_WGT={amt} WHERE C_ID='{cId}'";

                //                    var updateRlt = TransactionHelper.ExecuteSql(updateSql);

                //                    if (updateRlt != 1)
                //                    {
                //                        throw new Exception("更新库存失败");
                //                    }
                //                }

                var rlt = TransactionHelper.ExecuteSql(sql) > 0;

                if (!rlt)
                {
                    throw new Exception("完工失败");
                }

                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据发运单号更新线材实绩
        /// </summary>
        /// <param name="idstr">id字符串</param>
        /// <returns></returns>
        public int BJBynum(string idstr)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE TSC_SLAB_MAIN SET");
            strSql.Append(" C_FRFLAG='1'");
            strSql.Append("  where C_ID IN(" + idstr + ")");
            return(TransactionHelper.ExecuteSql(strSql.ToString()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新发运单状态
        /// </summary>
        /// <param name="dh">发运单号</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public int UPFYDSTATUS_Tran(string dh, string status)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE TMD_DISPATCH SET");
            strSql.Append(" C_STATUS='" + status + "'");
            strSql.Append(" WHERE C_ID ='" + dh + "'");
            return(TransactionHelper.ExecuteSql(strSql.ToString()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 根据idstr更新钢坯库存状态
        /// </summary>
        /// <param name="idstr">库存钢坯id字符串</param>
        /// <param name="type">状态</param>
        /// <param name="status">要变更的状态</param>
        /// <returns></returns>
        public int UPSLABSTATUS_Tran(string dh, string status)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE TSC_SLAB_MAIN SET");
            strSql.Append(" C_MOVE_TYPE='" + status + "' , C_FRFLAG=''");
            strSql.Append(" WHERE C_FYDH ='" + dh + "' ");
            return(TransactionHelper.ExecuteSql(strSql.ToString()));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据转库单获取数据
        /// </summary>
        /// <param name="dh"></param>
        /// <returns></returns>
        public DataSet GetListBydh(string dh)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select C_ID,C_ZKD_NO,C_MAT_CODE,C_MAT_DESC,C_LINEWH_ID,C_MBLINEWH_ID,C_LINEWH_CODE,C_MBLINEWH_CODE,C_STL_GRD,C_JUDGE_LEV_ZH,N_NUM,N_WGT,C_Z_DW,C_F_DW,C_BATCH_NO,C_SPEC,C_STOVE,C_ZYX1,C_ZYX2,C_BZYQ,C_ZYX4,N_STATUS,C_EMP_ID,D_MOD_DT ,N_SJNUM,N_SJWGT");
            strSql.Append(" FROM TRC_ROLL_ZKD WHERE N_STATUS<>2");
            if (dh.Trim() != "")
            {
                strSql.Append(" AND C_ZKD_NO ='" + dh + "' ");
            }
            return(TransactionHelper.Query(strSql.ToString()));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根据发运单号获取中间表数据
        /// </summary>
        /// <param name="dhstr">发运单号</param>
        /// <returns></returns>
        public DataSet GetZJBList(string dhstr)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select C_ID,C_DISPATCH_ID,C_SEND_STOCK,N_NUM,C_CKDH,N_WGT,N_JZ,C_STOVE,C_BATCH_NO,C_PLAN_ID,C_STL_GRD,C_STD_CODE,C_SPEC,C_PK_NCID,C_MZDATE,N_MWGT,N_PWGT,N_MZTIME,N_PZTIME,C_PZDATE,C_ZLDJ,C_BZYQ");
            strSql.Append(" FROM TMD_DISPATCH_SJZJB WHERE 1=1 ");
            if (dhstr.Trim() != "")
            {
                strSql.Append(" AND C_DISPATCH_ID='" + dhstr + "'");
            }
            return(TransactionHelper.Query(strSql.ToString()));
        }
Exemplo n.º 8
0
 /// <summary>
 /// 根据idstr更新钢坯库存状态
 /// </summary>
 /// <param name="idstr">库存钢坯id字符串</param>
 /// <returns></returns>
 public string GPFY(string dh)
 {
     TransactionHelper.BeginTransaction();
     if (UPSLABSTATUS_Tran(dh, "S") == 0)
     {
         return("变更钢坯状态错误!");
     }
     if (UPFYDSTATUS_Tran(dh, "8") == 0)
     {
         return("变更发运单状态错误!");
     }
     TransactionHelper.Commit();
     return("1");
 }
Exemplo n.º 9
0
        /// <summary>
        /// 获取最新的钢坯出库单号
        /// </summary>
        /// <param name="ckdh">出库单号</param>
        /// <returns></returns>
        public string GetCKDNO(string ckdh)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MAX(C_CKDH) ");
            strSql.Append(" FROM TMD_DISPATCH_SJZJB WHERE 1=1 ");
            if (ckdh.Trim() != "")
            {
                strSql.Append(" AND C_CKDH LIKE 'GP" + ckdh + "%' ");
            }
            object obj = TransactionHelper.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return("0");
            }
            else
            {
                return(obj.ToString());
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 修改批次号,如果录入了成分,需要把成分的批次号更新
        /// </summary>
        /// <param name="model"></param>
        /// <param name="newBatchNo"></param>
        public void UpdateBatchNo(Mod_TRC_ROLL_WW_MAIN model, string newBatchNo)
        {
            try
            {
                // 采取事物控制
                TransactionHelper.BeginTransaction();
                // 更新成分信息
                string updateSql1 = $"UPDATE TQC_COMPRE_ITEM_RESULT SET C_BATCH_NO='{newBatchNo}' WHERE C_BATCH_NO='{model.C_BATCH_NO}'";
                // 组批计划更新批号
                string updateSql2 = $"UPDATE TRC_ROLL_WW_MAIN SET C_BATCH_NO='{newBatchNo}' WHERE C_BATCH_NO='{model.C_BATCH_NO}'";

                TransactionHelper.ExecuteSql(updateSql1);
                TransactionHelper.ExecuteSql(updateSql2);
                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();

                throw new Exception("修改批次号失败");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 撤销外委组批
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="num"></param>
        public void CancelZpInfo(string itemId, decimal num)
        {
            var zpInfo = GetModel(itemId);

            if (zpInfo == null)
            {
                throw new Exception("未找到组批数据,请重试");
            }

            if (zpInfo.N_STATUS != 0)
            {
                throw new Exception("不能撤销,数据已经被操作");
            }

            if (zpInfo.N_QUA_TOTAL < num)
            {
                throw new Exception($"退库数量不能大于{zpInfo.N_QUA_TOTAL}");
            }

            TransactionHelper.BeginTransaction();
            try
            {
                var lstItems = GetWWItemByZpId(zpInfo.C_ID);

                // 部分撤销
                if (lstItems.Count < num)
                {
                    throw new Exception($"数据错误,退库数量不能大于{zpInfo.N_QUA_TOTAL}");
                }

                var delItems = lstItems.Take((int)num);

                if (zpInfo.N_QUA_TOTAL == num)
                {
                    // 全部撤销,删除子表及主表记录
                    string delItemSql = $"DELETE TRC_ROLL_WW_MAIN_ITEM WHERE C_ROLL_WW_MAIN_ID='{zpInfo.C_ID}'";
                    TransactionHelper.ExecuteSql(delItemSql);
                    string delSql = $"DELETE TRC_ROLL_WW_MAIN WHERE C_ID='{zpInfo.C_ID}'";
                    TransactionHelper.ExecuteSql(delSql);

                    // 退库
                }
                else
                {
                    // 剩余的重量,用于更新
                    var wgt = lstItems.Skip((int)num).Sum(w => w.N_WGT);

                    // 删除的ID
                    var delIds = "('" + string.Join("','", delItems.Select(w => w.C_ID)) + "')";
                    var delSql = $"DELETE TRC_ROLL_WW_MAIN_ITEM WHERE C_ID IN{delIds}";
                    TransactionHelper.ExecuteSql(delSql);

                    // 更新主表支数,重量
                    string updateSql = $"UPDATE TRC_ROLL_WW_MAIN " +
                                       $"SET N_QUA_TOTAL={lstItems.Count - num},N_WGT_TOTAL={wgt} WHERE C_ID='{zpInfo.C_ID}'";
                    TransactionHelper.ExecuteSql(updateSql);
                }

                // 退库
                var    updateIds        = "('" + string.Join("','", delItems.Select(w => w.C_SLAB_MAIN_ID)) + "')";
                string updateProductSql = $"UPDATE TRC_ROLL_PRODCUT SET C_MOVE_TYPE = 'QE' WHERE C_ID IN{updateIds}";
                TransactionHelper.ExecuteSql(updateProductSql);
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                throw ex;
            }

            TransactionHelper.Commit();
        }
Exemplo n.º 12
0
        /*
         *      /// <summary>
         *      /// 分页获取数据列表
         *      /// </summary>
         *      public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         *      {
         *              OracleParameter[] parameters = {
         *                              new OracleParameter(":tblName", OracleDbType.Varchar2, 255),
         *                              new OracleParameter(":fldName", OracleDbType.Varchar2, 255),
         *                              new OracleParameter(":PageSize", OracleDbType.Decimal),
         *                              new OracleParameter(":PageIndex", OracleDbType.Decimal),
         *                              new OracleParameter(":IsReCount", OracleDbType.Clob),
         *                              new OracleParameter(":OrderType", OracleDbType.Clob),
         *                              new OracleParameter(":strWhere", OracleDbType.Varchar2,1000),
         *                              };
         *              parameters[0].Value = "TRC_ROLL_WW_MAIN";
         *              parameters[1].Value = "C_ID";
         *              parameters[2].Value = PageSize;
         *              parameters[3].Value = PageIndex;
         *              parameters[4].Value = 0;
         *              parameters[5].Value = 0;
         *              parameters[6].Value = strWhere;
         *              return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         *      }*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod

        #region 自定义
        /// <summary>
        /// 外委加工组批
        /// </summary>
        /// <param name="zpInfo"></param>
        public void SetZpInfo(
            Mod_TMO_ORDER order,
            WWZPPlanItemInfo zpInfo,
            List <Mod_TRC_ROLL_PRODCUT> batchInfo,
            string userId)
        {
            UpdateBatchSameToNc(
                zpInfo.InventoryCode,
                order.C_STL_GRD,
                order.C_STD_CODE,
                order.C_SPEC,
                zpInfo.CBatchNo,
                zpInfo.MtrlCode,
                zpInfo.ZLDJ,
                zpInfo.BZYQ,
                batchInfo);

            TransactionHelper.BeginTransaction();

            if (zpInfo.Num < batchInfo.Count)
            {
                // 如果组批支数等于库存支数,相当于耗用所有库存,则实际重量等于库存重量
                new Dal_TMO_ORDER().UpdateInventory(batchInfo, zpInfo.ZpAmt, zpInfo.Num);
            }

            var zpAmt = batchInfo.Take(zpInfo.Num).Sum(w => w.N_WGT);

            // 生成批次号
            var batchInfoItem = batchInfo.FirstOrDefault();
            // 构造外委加工组批主表记录
            var mainItem = new Mod_TRC_ROLL_WW_MAIN
            {
                C_ID              = Guid.NewGuid().ToString("N"),
                C_ORD_ID          = zpInfo.Id,
                N_WGT_TOTAL       = zpAmt,
                N_STATUS          = 0,
                C_EMP_ID          = userId,
                C_GROUP           = zpInfo.BZ,
                C_REMARK          = zpInfo.Remark,
                C_SHIFT           = zpInfo.BC,
                C_SPEC_SLAB       = batchInfoItem.C_SPEC,
                C_CHECKSTATE_NAME = zpInfo.ZLDJ,
                C_STD_CODE        = batchInfoItem.C_STD_CODE,
                C_STL_GRD_SLAB    = batchInfoItem.C_STL_GRD,
                D_MOD_DT          = DateTime.Now,
                N_QUA_TOTAL       = zpInfo.Num,
                C_MAT_SLAB_CODE   = order.C_MAT_CODE,
                C_MAT_SLAB_NAME   = order.C_MAT_NAME,
                C_MAT_XC_CODE     = batchInfoItem.C_MAT_CODE,
                C_MAT_XC_NAME     = batchInfoItem.C_MAT_DESC,
                C_XC_BATCH_NO     = batchInfoItem.C_BATCH_NO,
                C_XC_LINEWH_CODE  = batchInfoItem.C_LINEWH_CODE,// zpInfo.InventoryCode,
                C_XC_BZYQ         = batchInfoItem.C_BZYQ
            };

            if (string.IsNullOrEmpty(zpInfo.BachNo) == false)
            {
                var a = ExistBatchNo(zpInfo.BachNo);
                // 验证批号
                //string existsSql = $"SELECT COUNT(C_ID) FROM TRC_ROLL_WW_MAIN WHERE C_BATCH_NO='{zpInfo.BachNo}'";
                //var count = int.Parse(TransactionHelper.Query(existsSql).Tables[0].Rows[0][0]?.ToString() ?? "0");
                if (a)//count > 0)
                {
                    TransactionHelper.RollBack();
                    throw new Exception("批次号重复,请重新输入");
                }

                mainItem.C_BATCH_NO = zpInfo.BachNo;
            }
            else
            {
                mainItem.C_BATCH_NO = GetMAXWWBatchNo();
            }

            bool success = this.Add(mainItem);

            if (success == false)
            {
                TransactionHelper.RollBack();
                throw new Exception("组批失败");
            }
            try
            {
                for (int i = 0; i < zpInfo.Num; i++)
                {
                    // 更新线材库存状态
                    string updateSql = $"UPDATE TRC_ROLL_PRODCUT SET C_MOVE_TYPE = 'QS' WHERE C_ID='{batchInfo[i].C_ID}'";

                    TransactionHelper.ExecuteSql(updateSql);

                    // 插入外委加工组批子表记录
                    string insertSql = $"insert into TRC_ROLL_WW_MAIN_ITEM(C_ID,C_ROLL_WW_MAIN_ID,C_SLAB_MAIN_ID,N_WGT) " +
                                       $"VALUES('{Guid.NewGuid().ToString("N")}','{mainItem.C_ID}','{batchInfo[i].C_ID}',{batchInfo[i].N_WGT})";

                    TransactionHelper.ExecuteSql(insertSql);
                }
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                throw ex;
            }

            TransactionHelper.Commit();
        }
Exemplo n.º 13
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Mod_TRC_ROLL_WW_MAIN model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TRC_ROLL_WW_MAIN(");
            strSql.Append("C_ID,C_STA_ID,C_PLANT,C_ORD_ID,C_BATCH_NO,N_QUA_TOTAL,N_WGT_TOTAL,C_STL_GRD_SLAB,C_SPEC_SLAB,C_EMP_ID,C_SHIFT,C_GROUP,D_MOD_DT,N_QUA_REMOVE,N_WGT_REMOVE,C_MAT_SLAB_CODE,C_MAT_SLAB_NAME,C_REMARK,N_STATUS,C_STD_CODE,D_PRODUCE_DATE_B,C_PRODUCE_EMP_ID,C_PRODUCE_SHIFT,C_PRODUCE_GROUP,D_PRODUCE_DATE_E,C_MAT_XC_CODE,C_MAT_XC_NAME,C_XC_BATCH_NO,C_XC_LINEWH_CODE,C_CHECKSTATE_NAME,C_LINEWH_CODE,C_LINEWH_NAME,C_XC_BZYQ)");
            strSql.Append(" values (");
            strSql.Append(":C_ID,:C_STA_ID,:C_PLANT,:C_ORD_ID,:C_BATCH_NO,:N_QUA_TOTAL,:N_WGT_TOTAL,:C_STL_GRD_SLAB,:C_SPEC_SLAB,:C_EMP_ID,:C_SHIFT,:C_GROUP,:D_MOD_DT,:N_QUA_REMOVE,:N_WGT_REMOVE,:C_MAT_SLAB_CODE,:C_MAT_SLAB_NAME,:C_REMARK,:N_STATUS,:C_STD_CODE,:D_PRODUCE_DATE_B,:C_PRODUCE_EMP_ID,:C_PRODUCE_SHIFT,:C_PRODUCE_GROUP,:D_PRODUCE_DATE_E,:C_MAT_XC_CODE,:C_MAT_XC_NAME,:C_XC_BATCH_NO,:C_XC_LINEWH_CODE,:C_CHECKSTATE_NAME,:C_LINEWH_CODE,:C_LINEWH_NAME,:C_XC_BZYQ)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID",              OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STA_ID",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_PLANT",           OracleDbType.Varchar2, 100),
                new OracleParameter(":C_ORD_ID",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_BATCH_NO",        OracleDbType.Varchar2, 100),
                new OracleParameter(":N_QUA_TOTAL",       OracleDbType.Decimal,   15),
                new OracleParameter(":N_WGT_TOTAL",       OracleDbType.Decimal,   15),
                new OracleParameter(":C_STL_GRD_SLAB",    OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC_SLAB",       OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EMP_ID",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SHIFT",           OracleDbType.Varchar2, 100),
                new OracleParameter(":C_GROUP",           OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT",          OracleDbType.Date),
                new OracleParameter(":N_QUA_REMOVE",      OracleDbType.Decimal,   15),
                new OracleParameter(":N_WGT_REMOVE",      OracleDbType.Decimal,   15),
                new OracleParameter(":C_MAT_SLAB_CODE",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MAT_SLAB_NAME",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_REMARK",          OracleDbType.Varchar2, 500),
                new OracleParameter(":N_STATUS",          OracleDbType.Decimal,   15),
                new OracleParameter(":C_STD_CODE",        OracleDbType.Varchar2, 100),
                new OracleParameter(":D_PRODUCE_DATE_B",  OracleDbType.Date),
                new OracleParameter(":C_PRODUCE_EMP_ID",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_PRODUCE_SHIFT",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_PRODUCE_GROUP",   OracleDbType.Varchar2, 100),
                new OracleParameter(":D_PRODUCE_DATE_E",  OracleDbType.Date),
                new OracleParameter(":C_MAT_XC_CODE",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MAT_XC_NAME",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_XC_BATCH_NO",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_XC_LINEWH_CODE",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_CHECKSTATE_NAME", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_LINEWH_CODE",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_LINEWH_NAME",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_XC_BZYQ",         OracleDbType.Varchar2, 100),
            };
            parameters[0].Value  = model.C_ID;
            parameters[1].Value  = model.C_STA_ID;
            parameters[2].Value  = model.C_PLANT;
            parameters[3].Value  = model.C_ORD_ID;
            parameters[4].Value  = model.C_BATCH_NO;
            parameters[5].Value  = model.N_QUA_TOTAL;
            parameters[6].Value  = model.N_WGT_TOTAL;
            parameters[7].Value  = model.C_STL_GRD_SLAB;
            parameters[8].Value  = model.C_SPEC_SLAB;
            parameters[9].Value  = model.C_EMP_ID;
            parameters[10].Value = model.C_SHIFT;
            parameters[11].Value = model.C_GROUP;
            parameters[12].Value = model.D_MOD_DT;
            parameters[13].Value = model.N_QUA_REMOVE;
            parameters[14].Value = model.N_WGT_REMOVE;
            parameters[15].Value = model.C_MAT_SLAB_CODE;
            parameters[16].Value = model.C_MAT_SLAB_NAME;
            parameters[17].Value = model.C_REMARK;
            parameters[18].Value = model.N_STATUS;
            parameters[19].Value = model.C_STD_CODE;
            parameters[20].Value = model.D_PRODUCE_DATE_B;
            parameters[21].Value = model.C_PRODUCE_EMP_ID;
            parameters[22].Value = model.C_PRODUCE_SHIFT;
            parameters[23].Value = model.C_PRODUCE_GROUP;
            parameters[24].Value = model.D_PRODUCE_DATE_E;
            parameters[25].Value = model.C_MAT_XC_CODE;
            parameters[26].Value = model.C_MAT_XC_NAME;
            parameters[27].Value = model.C_XC_BATCH_NO;
            parameters[28].Value = model.C_XC_LINEWH_CODE;
            parameters[29].Value = model.C_CHECKSTATE_NAME;
            parameters[30].Value = model.C_LINEWH_CODE;
            parameters[31].Value = model.C_LINEWH_NAME;
            parameters[32].Value = model.C_XC_BZYQ;


            int rows = TransactionHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Mod_TRC_ROLL_ZKD model, bool flag = false)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TRC_ROLL_ZKD(");
            strSql.Append("C_ZKD_NO,C_MAT_CODE,C_MAT_DESC,C_LINEWH_CODE,C_MBLINEWH_CODE,C_STL_GRD,C_JUDGE_LEV_ZH,N_NUM,N_WGT,C_Z_DW,C_F_DW,C_BATCH_NO,C_SPEC,C_STOVE,C_ZYX1,C_ZYX2,C_BZYQ,C_ZYX4,N_STATUS,C_EMP_ID,D_MOD_DT,D_PRODUCE_DATE,C_TB,C_JUDGE_LEV_BP,C_STD_CODE,C_LINEWH_ID,C_MBLINEWH_ID,C_CREATE_CODE,D_CREATE_DATE,N_SJNUM,N_SJWGT)");
            strSql.Append(" values (");
            strSql.Append(":C_ZKD_NO,:C_MAT_CODE,:C_MAT_DESC,:C_LINEWH_CODE,:C_MBLINEWH_CODE,:C_STL_GRD,:C_JUDGE_LEV_ZH,:N_NUM,:N_WGT,:C_Z_DW,:C_F_DW,:C_BATCH_NO,:C_SPEC,:C_STOVE,:C_ZYX1,:C_ZYX2,:C_BZYQ,:C_ZYX4,:N_STATUS,:C_EMP_ID,:D_MOD_DT,:D_PRODUCE_DATE,:C_TB,:C_JUDGE_LEV_BP,:C_STD_CODE,:C_LINEWH_ID,:C_MBLINEWH_ID,:C_CREATE_CODE,:D_CREATE_DATE,:N_SJNUM,:N_SJWGT)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ZKD_NO",        OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MAT_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MAT_DESC",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_LINEWH_CODE",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MBLINEWH_CODE", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STL_GRD",       OracleDbType.Varchar2, 100),
                new OracleParameter(":C_JUDGE_LEV_ZH",  OracleDbType.Varchar2, 100),
                new OracleParameter(":N_NUM",           OracleDbType.Int16,     15),
                new OracleParameter(":N_WGT",           OracleDbType.Decimal,   15),
                new OracleParameter(":C_Z_DW",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_F_DW",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_BATCH_NO",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STOVE",         OracleDbType.Varchar2, 100),
                new OracleParameter(":C_ZYX1",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_ZYX2",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_BZYQ",          OracleDbType.Varchar2, 100),
                new OracleParameter(":C_ZYX4",          OracleDbType.Varchar2, 100),
                new OracleParameter(":N_STATUS",        OracleDbType.Int16,      1),
                new OracleParameter(":C_EMP_ID",        OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT",        OracleDbType.Date),
                new OracleParameter(":D_PRODUCE_DATE",  OracleDbType.Date),
                new OracleParameter(":C_TB",            OracleDbType.Varchar2, 100),
                new OracleParameter(":C_JUDGE_LEV_BP",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STD_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_LINEWH_ID",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_MBLINEWH_ID",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_CREATE_CODE",   OracleDbType.Varchar2, 100),
                new OracleParameter(":D_CREATE_DATE",   OracleDbType.Date),
                new OracleParameter(":N_SJNUM",         OracleDbType.Int16,     15),
                new OracleParameter(":N_SJWGT",         OracleDbType.Decimal, 15)
            };
            parameters[0].Value  = model.C_ZKD_NO;
            parameters[1].Value  = model.C_MAT_CODE;
            parameters[2].Value  = model.C_MAT_DESC;
            parameters[3].Value  = model.C_LINEWH_CODE;
            parameters[4].Value  = model.C_MBLINEWH_CODE;
            parameters[5].Value  = model.C_STL_GRD;
            parameters[6].Value  = model.C_JUDGE_LEV_ZH;
            parameters[7].Value  = model.N_NUM;
            parameters[8].Value  = model.N_WGT;
            parameters[9].Value  = model.C_Z_DW;
            parameters[10].Value = model.C_F_DW;
            parameters[11].Value = model.C_BATCH_NO;
            parameters[12].Value = model.C_SPEC;
            parameters[13].Value = model.C_STOVE;
            parameters[14].Value = model.C_ZYX1;
            parameters[15].Value = model.C_ZYX2;
            parameters[16].Value = model.C_BZYQ;
            parameters[17].Value = model.C_ZYX4;
            parameters[18].Value = model.N_STATUS;
            parameters[19].Value = model.C_EMP_ID;
            parameters[20].Value = model.D_MOD_DT;
            parameters[21].Value = model.D_PRODUCE_DATE;
            parameters[22].Value = model.C_TB;
            parameters[23].Value = model.C_JUDGE_LEV_BP;
            parameters[24].Value = model.C_STD_CODE;
            parameters[25].Value = model.C_LINEWH_ID;
            parameters[26].Value = model.C_MBLINEWH_ID;
            parameters[27].Value = model.C_CREATE_CODE;
            parameters[28].Value = model.D_CREATE_DATE;
            parameters[29].Value = model.N_SJNUM;
            parameters[30].Value = model.N_SJWGT;

            int rows = 0;

            if (flag)
            {
                rows = TransactionHelper.ExecuteSql(strSql.ToString(), parameters);
            }
            else
            {
                rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            }
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 发送发运单到中间表
        /// </summary>
        /// <param name="fydid">要发送的发运单号</param>
        /// <returns>返回int类型 1转入成功-1发送失败</returns>
        public string ADDFYDToZJB(string fydid, DateTime dateTime)
        {
            try
            {
                TransactionHelper.BeginTransaction();
                #region MyRegion
                string    rjhsql = "SELECT C_PLAN_ID,C_ID,C_MAT_CODE,C_STD_CODE,C_SEND_STOCK_CODE,c_Judge_Lev_Zh,C_PACK,N_FYZS,N_FYWGT,N_MWGT,N_PWGT,N_JWGT,C_MZDATE, C_PZDATE,N_MZTIME,N_PZTIME FROM TMD_DISPATCHDETAILS WHERE C_DISPATCH_ID='" + fydid + "'";
                DataTable plandt = TransactionHelper.Query(rjhsql).Tables[0];
                if (plandt.Rows.Count < 0)
                {
                    TransactionHelper.RollBack();
                    return("未查询到发运单子表数据!");
                }
                foreach (DataRow planrow in plandt.Rows)
                {
                    int    plannum = Convert.ToInt32(planrow["N_FYZS"]);//发运数量
                    string mzstr   = planrow["N_MWGT"].ToString();
                    string pzstr   = planrow["N_PWGT"].ToString();
                    string jzstr   = planrow["N_JWGT"].ToString();
                    #region 获取出库单
                    string no     = DateTime.Now.Year.ToString() + (Convert.ToInt32(DateTime.Now.Month) > 9 ? DateTime.Now.Month.ToString() : ("0" + DateTime.Now.Month.ToString())) + (Convert.ToInt32(DateTime.Now.Day) > 9 ? DateTime.Now.Day.ToString() : ("0" + DateTime.Now.Day.ToString())); //转库单号
                    string maxckd = GetCKDNO(no);                                                                                                                                                                                                                                                   //查询当天最大转库单
                    if (maxckd == "0")
                    {
                        no = no + "0001";
                    }
                    else
                    {
                        no = (Convert.ToInt64(maxckd.Substring(2, maxckd.Length - 2)) + 1).ToString();
                    }
                    no = "GP" + no;
                    #endregion
                    #region 获取钢坯实绩
                    DataTable dt1 = GetListByidstr(fydid, planrow["C_MAT_CODE"].ToString(), planrow["C_STD_CODE"].ToString(), planrow["C_SEND_STOCK_CODE"].ToString(), planrow["c_Judge_Lev_Zh"].ToString(), "1").Tables[0];//要传输的发运单数据
                    if (dt1.Rows.Count < 1)
                    {
                        TransactionHelper.RollBack();
                        return("根据发运单子表查询钢坯实绩错误!");
                    }
                    int fpnum = 0;
                    //string idstr = "";
                    foreach (DataRow xqitem in dt1.Rows)
                    {
                        fpnum += Convert.ToInt32(xqitem["N_NUM"]);
                        ////if (plannum == fpnum)
                        ////{
                        ////    break;
                        ////}
                        //idstr += "'" + xqitem["C_ID"] + "',";
                        //fpnum++;
                    }
                    //idstr = idstr.Substring(0, idstr.Length - 1);

                    //#region 变更钢坯实绩
                    //if (BJBynum(idstr) == 0)
                    //{
                    //    TransactionHelper.RollBack();
                    //    return "根据发运单子表变更钢坯实绩错误!";
                    //}
                    //#endregion
                    //DataTable sjdt = GetListByidstr(idstr).Tables[0];//要传输的发运单数据
                    if (mzstr == "")
                    {
                        foreach (DataRow item1 in dt1.Rows)
                        {
                            int num = Convert.ToInt32(item1["N_NUM"]);
                            #region 添加中间表
                            string sql = "";
                            sql += "insert into TMD_DISPATCH_SJZJB(C_DISPATCH_ID,N_NUM,N_STATUS,C_CKDH,C_SEND_STOCK,C_STOVE,C_BATCH_NO,C_PLAN_ID,C_STL_GRD,C_STD_CODE,C_SPEC,C_PK_NCID,C_ZLDJ,C_BZYQ,D_CKSJ,C_MAT_CODE,C_MAT_NAME,C_TICK_STR,N_WGT,N_JZ,N_MWGT,N_PWGT,C_MZDATE,C_PZDATE,N_MZTIME,N_PZTIME) values('" + fydid + "','" + num + "','6','" + no + "','" + item1["C_SLABWH_CODE"] + "','" + item1["C_STOVE"] + "','" + item1["C_BATCH_NO"] + "','" + planrow["C_PLAN_ID"].ToString() + "','" + item1["C_STL_GRD"] + "','" + item1["C_STD_CODE"] + "','" + item1["C_SPEC"] + "','" + planrow["C_ID"].ToString() + "','" + item1["C_JUDGE_LEV_ZH"].ToString() + "','',to_date('" + dateTime + "', 'yyyy-mm-dd hh24:mi:ss'),'" + item1["C_MAT_CODE"].ToString() + "','" + item1["C_MAT_NAME"].ToString() + "','','" + item1["N_WGT"].ToString() + "','','','','','','','')";
                            if (TransactionHelper.ExecuteSql(sql) == 0)
                            {
                                TransactionHelper.RollBack();
                                return("条件发运单中间表错误!");
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        decimal smz      = Convert.ToDecimal(planrow["N_MWGT"]); //总毛重
                        decimal spz      = Convert.ToDecimal(planrow["N_PWGT"]); //总皮重
                        decimal sjz      = Convert.ToDecimal(planrow["N_JWGT"]); //总净重
                        string  C_MZDATE = planrow["C_MZDATE"].ToString();       //获取毛重日期
                        string  C_PZDATE = planrow["C_PZDATE"].ToString();       //获取皮重日期
                        string  N_MZTIME = planrow["N_MZTIME"].ToString();       //获取毛重时间
                        string  N_PZTIME = planrow["N_PZTIME"].ToString();       //获取皮重时间
                        decimal mz       = smz / fpnum;                          //获取毛重
                        decimal pz       = spz / fpnum;                          //获取皮重
                        decimal jz       = sjz / fpnum;                          //获取净重
                        decimal bjmz     = 0;
                        decimal bjpz     = 0;
                        decimal bjjz     = 0;
                        int     bjnum    = 0;
                        foreach (DataRow item1 in dt1.Rows)
                        {
                            int     num  = Convert.ToInt32(item1["N_NUM"]);
                            decimal sjmz = decimal.Round(mz * num, 2);
                            decimal sjpz = decimal.Round(pz * num, 2);
                            decimal sjjz = decimal.Round(jz * num, 2);
                            bjnum++;
                            bjmz += sjmz;
                            bjpz += sjpz;
                            bjjz += sjjz;
                            if (bjnum == dt1.Rows.Count)
                            {
                                sjmz = smz - bjmz;
                                sjpz = spz - bjpz;
                                sjjz = sjz - bjjz;
                            }
                            #region 添加中间表
                            string sql = "";
                            sql += "insert into TMD_DISPATCH_SJZJB(C_DISPATCH_ID,N_NUM,N_STATUS,C_CKDH,C_SEND_STOCK,C_STOVE,C_BATCH_NO,C_PLAN_ID,C_STL_GRD,C_STD_CODE,C_SPEC,C_PK_NCID,C_ZLDJ,C_BZYQ,D_CKSJ,C_MAT_CODE,C_MAT_NAME,C_TICK_STR,N_WGT,N_JZ,N_MWGT,N_PWGT,C_MZDATE,C_PZDATE,N_MZTIME,N_PZTIME) values('" + fydid + "','" + num + "','6','" + no + "','" + item1["C_SLABWH_CODE"] + "','" + item1["C_STOVE"] + "','" + item1["C_BATCH_NO"] + "','" + planrow["C_PLAN_ID"].ToString() + "','" + item1["C_STL_GRD"] + "','" + item1["C_STD_CODE"] + "','" + item1["C_SPEC"] + "','" + planrow["C_ID"].ToString() + "','" + item1["C_JUDGE_LEV_ZH"].ToString() + "','',to_date('" + dateTime + "', 'yyyy-mm-dd hh24:mi:ss'),'" + item1["C_MAT_CODE"].ToString() + "','" + item1["C_MAT_NAME"].ToString() + "','','" + item1["N_WGT"].ToString() + "','" + sjjz + "','" + sjmz + "','" + sjpz + "','" + C_MZDATE + "','" + C_PZDATE + "','" + N_MZTIME + "','" + N_MZTIME + "')";
                            if (TransactionHelper.ExecuteSql(sql) == 0)
                            {
                                TransactionHelper.RollBack();
                                return("条件发运单中间表错误!");
                            }
                        }

                        #endregion
                    }
                    #endregion
                }
                #endregion

                TransactionHelper.Commit();
                return("1");
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return(ex.ToString());
            }
        }