예제 #1
0
        /// <summary>
        /// 生成下架任务
        /// </summary>
        /// <param name="outStockModel"></param>
        /// <param name="strErrMsg"></param>
        /// <returns></returns>
        public bool CreateOutStokTask(OutStock_Model outStockModel, ref string strErrMsg)
        {
            try
            {
                bool bSucc = false;

                if (outStockModel == null)
                {
                    strErrMsg = "客户端传来实体类表头数据为空!";
                    return(false);
                }

                if (outStockModel.lstOutStockDetails == null || outStockModel.lstOutStockDetails.Count == 0)
                {
                    strErrMsg = "客户端传来实体类表体数据为空!";
                    return(false);
                }

                if (outStockModel.lstOutStockDetails.Where(t => t.CurrentOutStockQty == 0).Count() == outStockModel.lstOutStockDetails.Count)
                {
                    strErrMsg = "领料数量都为零,不能生成下架任务!";
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                strErrMsg = "Web异常:" + ex.Message + ex.StackTrace;
                return(false);
            }
        }
예제 #2
0
 private void GetMaterialSumByKeeper(OutStock_Model outStockModel)
 {
     //var lstOutSrockDetails = outStockModel.lstOutStockDetails.GroupBy(s => s.MaterialKeeperNo).Select(g => new OutStockDetails_Model
     //{
     //    MaterialNo = g.FirstOrDefault().MaterialNo,
     //    MaterialDesc = g.FirstOrDefault().MaterialDesc,
     //    Plant = g.FirstOrDefault().Plant,
     //    StorageLoc = g.FirstOrDefault().StorageLoc,
     //    VoucherNo = g.
     //}).Where(t => t.VoterQty != 0).ToList();
 }
예제 #3
0
        /// <summary>
        /// 生成下架任务
        /// </summary>
        /// <param name="vouchcode"></param>
        /// <param name="vouchtype"></param>
        /// <param name="cwhcode"></param>
        /// <param name="userModel"></param>
        /// <param name="strTaskNo"></param>
        /// <param name="strErrMsg"></param>
        /// <returns></returns>
        public bool CreateUnShelveTask(string vouchcode, string vouchtype, string cwhcode, UserInfo userModel, ref string strTaskNo, ref string strErrMsg)
        {
            OutStock_Model osm = new OutStock_Model();

            WarehouseInfo whm = new WarehouseInfo();

            whm.WarehouseNo = cwhcode;
            Warehouse_Func wf = new Warehouse_Func();

            if (!wf.ExistsWarehouseNo(whm, false, userModel, ref strErrMsg))
            {
                return(false);
            }
            wf.GetWarehouseByID(ref whm, userModel, ref strErrMsg);
            DataSet result = new DataSet();
            string  sql;

            try
            {
                switch (vouchtype)
                {
                case "-10":    //红字成品入库单
                {
                    //TODO:取单据表头
                    sql = string.Format("select cCode as MaterialDoc,CONVERT(varchar(100), dDate, 23) as MaterialDocDate,cast(cVouchType as int) as MaterialDocType from rdrecord10 where cCode='{0}'", vouchcode);
                    OperationSql.GetDatasetForERP(sql, out result, out strErrMsg);
                    if (!string.IsNullOrEmpty(strErrMsg))
                    {
                        return(false);
                    }
                    List <MaterialDoc_Model> lstMaterialDoc = TOOL.DataTableToList.DataSetToList <MaterialDoc_Model>(result.Tables[0]);
                    if (lstMaterialDoc != null && lstMaterialDoc.Count > 0)
                    {
                        osm.materialDocModel = lstMaterialDoc[0];
                    }
                    osm = TOOL.DataTableToList.DataSetToList <OutStock_Model>(result.Tables[0])[0];
                    osm.IsOutStockPost    = 1;
                    osm.IsUnderShelvePost = 0;
                    osm.VoucherType       = 70;
                    //TODO:取单据表体
                    sql = string.Format(@"select rd.cCode as VoucherNo,rds.iRSRowNO RowNo,rds.cInvCode MaterialNo,i.cInvName MaterialDesc,i.cinvstd MaterialStd,
rds.iQuantity OutStockQty, rd.cWhCode StorageLoc
 from rdrecord10 rd
join rdrecords10 rds on rd.ID = rds.ID
join inventory i on rds.cInvCode = i.cInvCode
 where rd.cCode='{0}'", vouchcode);
                    OperationSql.GetDatasetForERP(sql, out result, out strErrMsg);
                    if (!string.IsNullOrEmpty(strErrMsg))
                    {
                        return(false);
                    }
                    osm.lstOutStockDetails = TOOL.DataTableToList.DataSetToList <OutStockDetails_Model>(result.Tables[0]);
                }
                break;
                }
            }
            catch (Exception)
            {
                throw;
            }
            #region 原先存储过程中定义的变量
            //           --------------------?? outstock ?? ----------------------------
            int    out_id;
            string out_no;
            int    out_isoutstockpost;
            int    out_isundershelvepost;
            int    out_vouchertype;
            string out_movetype;

            //           -------------------?? outstockdetails ?? -----------------------
            int    outd_id;
            string outd_voucherno;
            string outd_rowno;
            string outd_materialno;
            string outd_materialdesc;
            string outd_materialstd;
            double outd_outstockqty;
            string outd_unit;
            //           ----------------?? task ?? ----------------------------------------
            int    t_id;
            string t_taskno;

            //           ---------------?? taskdetails ?? -----------------------------------
            int td_id;
            //           ----------------userinfo---------------------------- -
            string useer_no = userModel.UserNo;;
            int    user_id  = userModel.ID;
            //           -----------------?? materialdoc ?? ------------------------------
            int      md_id;
            string   md_doc;
            string   md_docdate;
            DateTime md_postdate;
            int      md_type;


            //           ----------------warehouse----------------------------
            int warehouse_id;
            int taskwarehouse_id;

            int rectrans_id;
            #endregion



            SqlCommand     cmd  = new SqlCommand();
            SqlConnection  conn = new SqlConnection();
            SqlDataAdapter adp  = new SqlDataAdapter();
            conn.ConnectionString = OperationSql.connectionString;
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message;
                return(false);
            }
            SqlTransaction myTran;
            myTran          = conn.BeginTransaction();
            cmd.Connection  = conn;
            cmd.Transaction = myTran;

            try
            {
                //-----------------------插入任务表头数据------------------------
                //设置要调用的存储过程的名称
                cmd.CommandText = "P_GetNewSeqVal_SEQ_OUTSTOCK";
                //指定SqlCommand对象传给数据库的是存储过程的名称而不是sql语句
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
                //指定"@ID"为输出参数
                cmd.Parameters[0].Direction = ParameterDirection.Output;
                //执行
                cmd.ExecuteNonQuery();
                out_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                cmd.CommandText = "P_GetNewSeqVal_SEQ_TASK";
                cmd.ExecuteNonQuery();
                t_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                cmd.CommandText = "P_GetNewSeqVal_SEQ_TASKNO";
                cmd.ExecuteNonQuery();
                t_taskno = DateTime.Now.ToString("yyyyMMdd") + Convert.ToString(cmd.Parameters["@ID"].Value).PadLeft(4, '0');

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Clear();

                out_no                = osm.MaterialDoc;
                out_isoutstockpost    = osm.IsOutStockPost;
                out_isundershelvepost = osm.IsUnderShelvePost;
                out_vouchertype       = osm.VoucherType;
                out_movetype          = osm.MoveType;

                //            --插入出库主表数据
                //insert into t_outstock(id, voucherno, vouchertype, customercode, customername, createdate, creater, isoutstockpost, isundershelvepost, plant, plantname, movetype)
                //values(ot_id, outStockRow.VoucherNo, outStockRow.VoucherType, outStockRow.CustomerCode, outStockRow.CustomerName, sysdate, strUserNo, outStockRow.IsOutStockPost,
                //outStockRow.IsUnderShelvePost, outStockRow.Plant, outStockRow.PlantName, outStockRow.Movetype);
                sql             = string.Format(@"insert into t_outstock(id,voucherno,vouchertype,customercode,customername,createdate,creater,isoutstockpost,isundershelvepost,movetype)
    values({0},'{1}','{2}','{3}','{4}',getdate(),'{5}','{6}',
    '{7}','{8}'); ", out_id, out_no, out_vouchertype, "", "", useer_no, out_isoutstockpost, out_isundershelvepost, out_movetype);
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();

                //           insert into t_task(id, vouchertype, tasktype, taskno, supcusname, taskstatus, createdatetime, supcusno,
                //createuserno, receive_id, deliveryno, isquality, isreceivepost, isshelvepost, plant, plantname, receiveuserno, taskissued, movetype)
                //values
                //(t_id, rec_vouchertype, '1', t_taskno, rec_suppliername, (case rec_isquality when 1 then 2 when 2 then 3 end),sysdate,rec_supplierno,struserno,
                //rec_id,rec_no,rec_isquality,rec_isreceivepost,rec_isshelvepost,rec_plant,rec_plantname,struserno,
                //(case rec_isquality when 1 then sysdate  end),rec_movetype);
                sql = string.Format(@"insert into t_task(id,vouchertype,tasktype,taskno,supcusname,taskstatus,createdatetime,supcusno,
     createuserno,receive_id,deliveryno,isquality,isreceivepost,isshelvepost,receiveuserno,taskissued,movetype)
     values
     ({0},{1},'2','{2}','{3}',{4},getdate(),'{5}','{6}',
     {7},'{8}',{9},{10},{11},'{12}',{13},'{14}');"
                                    , t_id, out_vouchertype, t_taskno, "", 2, "", useer_no,
                                    out_id, out_no, 1, out_isoutstockpost, out_isundershelvepost, useer_no, "getdate()", out_movetype);
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();

                //--------------------插入物料凭证数据------------------------
                cmd.CommandText = "P_GetNewSeqVal_SEQ_MATERIALDOC";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
                cmd.Parameters[0].Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();
                md_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Clear();

                //when 'MaterialDoc' then
                md_doc = osm.materialDocModel.MaterialDoc;
                //when 'MaterialDocDate' then
                md_docdate = osm.materialDocModel.MaterialDocDate;
                //when 'MaterialDocType' then
                md_type = osm.materialDocModel.MaterialDocType;

                sql             = string.Format(@"insert into t_receivematerialdoc(id,receive_id,materialdoc,docdate,postdate,createdate,postuser,task_id,
         materialdoctype,taskdoctype)
         values({0},{1},'{2}','{3}',getdate(),getdate(),'{4}',{5},{6},1);", md_id, "null", md_doc, md_docdate, useer_no, t_id, md_type);
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();

                //----------------------插入任务对应仓库数据-------------------------- -
                cmd.CommandText = "P_GetNewSeqVal_SEQ_TASKWAREHOUSE";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
                cmd.Parameters[0].Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();
                taskwarehouse_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Clear();

                //when 'ID' then
                warehouse_id = whm.ID;

                //         insert into t_taskwarehouse(id, task_id, warehouse_id, user_id)
                //values
                //(taskwarehouse_id, t_id, warehouse_id, struserid);
                sql             = string.Format(@" insert into t_taskwarehouse (id,task_id,warehouse_id,user_id)
       values
       ({0},{1}, {2},{3} );", taskwarehouse_id, t_id, warehouse_id, user_id);
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();

                //----------------------插入任务明细数据-------------------------- -
                foreach (var item in osm.lstOutStockDetails)
                {
                    cmd.CommandText = "P_GetNewSeqVal_SEQ_OUTSTOCKDETAILS";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
                    cmd.Parameters[0].Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    outd_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                    cmd.CommandText = "P_GETNEWSEQVAL_SEQ_TASKDETAILS";
                    cmd.ExecuteNonQuery();
                    td_id = Convert.ToInt32(cmd.Parameters["@ID"].Value);

                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Clear();

                    //when 'VoucherNo' then
                    outd_voucherno = item.VoucherNo;
                    //when 'RowNo' then
                    outd_rowno = item.RowNo;
                    //when 'MaterialNo' then
                    outd_materialno = item.MaterialNo;
                    //when 'MaterialDesc' then
                    outd_materialdesc = item.MaterialDesc;
                    outd_materialstd  = item.MaterialStd;

                    //when 'CurrentlyDeliveryNum' then
                    outd_outstockqty = item.OutStockQty;
                    //when 'Unit' then
                    outd_unit = item.Unit;

                    sql = string.Format(@"insert into t_outstockdetails(id,outstock_id,voucherno,materialno,materialdesc,rowno,unit,
    outstockqty,oldoutstockqty ) values   
    ( {0},{1},'{2}','{3}','{4}','{5}','{6}',{7},{7})",
                                        outd_id, out_id, outd_voucherno, outd_materialno, outd_materialdesc, outd_rowno, outd_unit, outd_outstockqty);
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();

                    sql = string.Format(@"insert into t_taskdetails(id,materialno,materialdesc,materialstd,taskqty,
                    qualityqty,remainqty,shelveqty,status,isqualitycomp,task_id,
                    packcount,shelvepackcount,voucherno,rowno,createdate)
                    values
                    (  {0},'{1}','{2}','{3}',
                    {4},0,{4},0,1,1,{5},
                    0,0,{6},'{7}',getdate());",
                                        td_id, outd_materialno, outd_materialdesc, outd_materialstd, outd_outstockqty,
                                        t_id, outd_voucherno, outd_rowno);
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                }
                myTran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message;
                myTran.Rollback();
                return(false);
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
        }
예제 #4
0
 public bool CreateOutStokTask(OutStock_Model outStockModel, ref string strErrMsg)
 {
     return(true);
 }
예제 #5
0
        //public bool GetOutStockInfoForSAP(ref OutStock_Model outStockInfo, UserInfo userModel, ref string strErrMsg)
        //{
        //    try
        //    {
        //        bool bSucc = false;

        //        if (outStockInfo.VoucherType == 0)
        //        {
        //            strErrMsg = "领料单据类型错误,请确认!";
        //            return false;
        //        }

        //        if (string.IsNullOrEmpty(outStockInfo.VoucherNo))
        //        {
        //            strErrMsg = "请输入单据编号!";
        //            return false;
        //        }

        //        OutStock_Post OSP = OutStock_Factory.CreateFactoty(outStockInfo.VoucherType);

        //        bSucc = OSP.GetMaterialRequestInfoForSAP(ref outStockInfo, userModel, ref strErrMsg);

        //        if (outStockInfo.lstOutStockDetails == null || outStockInfo.lstOutStockDetails.Count == 0)
        //        {
        //            strErrMsg = "领料单表体数据为空!";
        //            bSucc = false;
        //        }

        //        bSucc = GetMaterialKeeper(ref outStockInfo, ref strErrMsg);

        //        GetVoucherTypeName(outStockInfo);

        //        return bSucc;
        //    }
        //    catch (Exception ex)
        //    {
        //        strErrMsg = "Web异常:" + ex.Message;
        //        return false;
        //    }
        //}

        //private bool GetMaterialKeeper(ref OutStock_Model outStockModel, ref string strErrMsg)
        //{
        //    List<Material.Material_Model> lstMaterialKeeper = new List<Material.Material_Model>();
        //    Material.Material_SAP MSAP=new Material.Material_SAP();

        //    bool bSucc = MSAP.GetMaterialKeeperForSAP(outStockModel, ref lstMaterialKeeper, ref strErrMsg);

        //    if (bSucc == false)
        //    {
        //        strErrMsg = strErrMsg + "\r\n物料对应保管员!";
        //        return bSucc;
        //    }

        //    if (lstMaterialKeeper == null || lstMaterialKeeper.Count == 0)
        //    {
        //        strErrMsg = "获取物料对应保管员失败!";
        //        return false;
        //    }

        //    foreach (var item in outStockModel.lstOutStockDetails)
        //    {
        //       var lstKeeper= lstMaterialKeeper.FindAll(delegate(Material.Material_Model OSDM) { return OSDM.MaterialNo == item.MaterialNo; });
        //       if (lstKeeper == null || lstKeeper.Count == 0)
        //       {
        //           bSucc = false;
        //           strErrMsg = "物料:" + item.MaterialNo + " 行号:" + item.RowNo + " 没有对应保管员!";
        //           break;
        //       }
        //       if (lstKeeper.Count == 1)
        //       {
        //           item.StorageLoc = lstKeeper[0].StorageLoc;
        //           item.MaterialKeeperName = lstKeeper[0].MaterialLeeperName;
        //           item.MaterialKeeperNo = lstKeeper[0].MaterialKeeperNo;
        //       }
        //    }

        //    return bSucc;

        //}

        private void GetVoucherTypeName(OutStock_Model outStockInfo)
        {
            int iVoucherType = outStockInfo.VoucherType;

            outStockInfo.lstOutStockDetails.ForEach(t => t.VoucherTypeName = SelectVoucherTypeName(iVoucherType));
        }
예제 #6
0
 public virtual bool GetMaterialRequestInfoForSAP(ref OutStock_Model outStockModel, UserInfo userModel, ref string strErrMsg)
 {
     return(true);
 }