/// <summary>
 /// 验证原库位能否移库
 /// </summary>
 /// <param name="CustomerID"></param>
 /// <param name="WarehouseName"></param>
 /// <param name="BoxNumber"></param>
 /// <returns></returns>
 public int CheckBoxNumber(long CustomerID, string WarehouseName, string BoxNumber)
 {
     try
     {
         string sqlCheck = (@"select id,SKU,InventoryType,Qty from WMS_Inventory_103 where  Warehouse='" + WarehouseName + @"' and Location='" + BoxNumber + @"'
         and InventoryType!=9");
         IEnumerable <Inventorys> inventorys = this.ScanDataTable(sqlCheck).ConvertToEntityCollection <Inventorys>();
         if (inventorys != null)
         {
             if (inventorys.Count() == 0)
             {
                 return(3);
             }
             if (inventorys.Where(a => a.InventoryType == 2 || a.InventoryType == 3).Count() < 1)
             {
                 return(1);
             }
             else
             {
                 return(2);
             }
         }
         else
         {
             return(0);
         }
         //return this.ScanExecuteNonQuery(sqlCheck);
         //return dt.ConvertToEntityCollection<Inventorys>();
     }
     catch (Exception ex)
     {
         SysLogWriter.Error("CheckBoxNumber(Dao层)" + BoxNumber + ex.ToString());
     }
     return(0);
 }
Esempio n. 2
0
        public int ScanExecuteNonQueryBySql(string Sql)
        {
            int            i    = 0;
            SqlConnection  conn = new SqlConnection(BaseAccessor._dataBase.ConnectionString);
            SqlTransaction transaction;

            conn.Open();
            transaction = conn.BeginTransaction();
            try
            {
                SqlCommand cmd = new SqlCommand(Sql, conn);
                cmd.Transaction = transaction;
                cmd.CommandType = CommandType.Text;
                //cmd.CommandText = Sql;
                cmd.CommandTimeout = 1800;
                i = cmd.ExecuteNonQuery();
                transaction.Commit();
                return(i);
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                SysLogWriter.Error("ScanExecuteNonQuery 数据库连接" + ex.ToString());
                return(i);
                //throw;
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 3
0
        public DataTable ScanDataTable(string Sql)
        {
            DataTable     dt   = new DataTable();
            SqlConnection conn = new SqlConnection(BaseAccessor._dataBase.ConnectionString);

            conn.Open();
            SqlTransaction transaction;

            transaction = conn.BeginTransaction();
            try
            {
                SqlCommand cmd = new SqlCommand(Sql, conn);
                cmd.Transaction    = transaction;
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 1800;


                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                sda.Fill(dt);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                SysLogWriter.Error("ScanDataTable 数据库连接" + ex.ToString());
            }
            finally
            {
                conn.Close();
                transaction.Dispose();
            }
            return(dt);
        }
Esempio n. 4
0
 public JsonResult MoveLocation(string BoxNumber, string NewLocation)
 {
     try
     {
         SysLogWriter.Error(Session["Name"].ToString() + "提交移库" + BoxNumber + ":" + NewLocation);
         var response = new InventoryManagementService().MoveLocation(long.Parse(Session["CustomerID"].ToString()), Session["WareHouseName"].ToString(), BoxNumber, NewLocation, Session["Name"].ToString());
         return(Json(new { Code = response }));
     }
     catch (Exception ex)
     {
         SysLogWriter.Error("MoveLocation(整箱)" + Session["Name"].ToString() + ex.ToString());
     }
     return(Json(new { Code = 0 }));
 }
Esempio n. 5
0
        /// <summary>
        /// 获取推荐箱
        /// </summary>
        /// <param name="BoxNumber"></param>
        /// <returns></returns>
        public JsonResult RefreshLocation(string BoxNumber, string Location)
        {
            BestLocationManagementService Service = new BestLocationManagementService();

            SysLogWriter.Error("获取推荐箱");
            try
            {
                var response = Service.RefreshLocation(Session["CustomerID"].ToString(), Session["WareHouseName"].ToString(), BoxNumber, Location);
                if (!string.IsNullOrEmpty(response))
                {
                    return(Json(new { Code = 0, Data = response }));
                }
                return(Json(new { Code = 0 }));
            }
            catch (Exception ex)
            {
                SysLogWriter.Error("获取推荐箱失败:" + ex.Message);
                return(Json(new { Code = 0 }));
            }
        }
Esempio n. 6
0
 public JsonResult CheckBoxNumber(string BoxNumber)
 {
     try
     {
         SysLogWriter.Error(Session["Name"].ToString() + "开始验证原库位" + BoxNumber);
         var response = new InventoryManagementService().CheckBoxNumber(long.Parse(Session["CustomerID"].ToString()), Session["WareHouseName"].ToString(), BoxNumber);
         if (response > 0)
         {
             return(Json(new { Code = response }));
         }
         else
         {
             return(Json(new { Code = 0 }));
         }
     }
     catch (Exception ex)
     {
         SysLogWriter.Error("CheckBoxNumber(整箱)" + Session["Name"].ToString() + ex.ToString());
     }
     return(Json(new { Code = 0 }));
 }
        /// <summary>
        /// 移库
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <param name="WarehouseName"></param>
        /// <param name="BoxNumber"></param>
        /// <param name="Location"></param>
        /// <param name="Creator"></param>
        /// <returns></returns>
        public int MoveLocation(long CustomerID, string WarehouseName, string BoxNumber, string Location, string Creator)
        {
            try
            {
                string SqlCheckLocation = @"select wl.* from WMS_Warehouse w left join WMS_Warehouse_Location wl
               on w.ID = wl.WarehouseID where wl.Location = '" + Location + @"'  and w.WarehouseName='" + WarehouseName + "' ";
                if (this.ScanDataTable(SqlCheckLocation).Rows.Count < 1)
                {
                    return(2);
                }
                string sqlCheck = (@"select * from WMS_Inventory_103 where  Warehouse='" + WarehouseName + @"' and Location='" + BoxNumber + @"'
                and InventoryType!=9");
                IEnumerable <Inventorys> inventorys = this.ScanDataTable(sqlCheck).ConvertToEntityCollection <Inventorys>();
                //提交前查看是否还有数据Check
                if (inventorys == null || inventorys.Count() == 0)
                {
                    return(0);
                }
                string AdjustmentNumber = "ADJ" + DateTime.Now.Ticks;
                //新建库存移动单
                string SqlAdjustment = (@"
              DECLARE @AID bigint; 
             insert into [WMS_Adjustment] ([AdjustmentNumber]
            ,[CustomerID]
            ,[CustomerName]
            ,[Warehouse]
            ,[Status]
            ,[AdjustmentType]
            ,[AdjustmentReason]
            ,[AdjustmentTime]
            ,[IsHold]
            ,[Creator]
            ,[CreateTime] 
            ,[Remark] ,Str3) values('" + AdjustmentNumber + @"'
            ,'" + inventorys.First().CustomerID + @"'
            ,'" + inventorys.First().CustomerName + @"'
            ,'" + inventorys.First().Warehouse + @"'
            ,1
            ,'库存移动单'
            ,'RF主动移库'
            ,getdate()
            ,0
            ,'" + Creator + @"'
            ,getdate()
            ,'RF主动移库','QQQQQQ' ) 
            set @AID=@@IDENTITY
            insert into  WMS_AdjustmentDetail ([AID]
            ,[AdjustmentNumber]
            ,[CustomerID]
            ,[CustomerName]
            ,[FromLot]
            ,[ToLot]
            ,[SKU]
            ,[UPC]
            ,[BatchNumber]
            ,[BoxNumber]
            ,[GoodsName]
            ,[FromWarehouse]
            ,[ToWarehouse]
            ,[FromArea]
            ,[ToArea]
            ,[FromLocation]
            ,[ToLocation]
            ,[FromQty]
            ,[ToQty]
            ,[FromGoodsType]
            ,[ToGoodsType]
            ,[Unit]
            ,[Specifications]
            ,[IsHold]
            ,[AdjustmentReason]
            ,[Creator]
            ,[CreateTime],Str3 ) (  select @AID,'" + AdjustmentNumber + @"', CustomerID,CustomerName,null,null,SKU,UPC,BatchNumber,BoxNumber,GoodsName,Warehouse,Warehouse,Area,Area,
             Location,'" + Location + @"',Qty,Qty,GoodsType,GoodsType,Unit,Specifications,0,'','" + Creator + @"',getdate(),Str3 from WMS_Inventory_103 where    InventoryType=1 and Warehouse='" + WarehouseName + "' and   Location='" + BoxNumber + @"' )
             select * from WMS_Adjustment where [CustomerID]=" + CustomerID + " and AdjustmentNumber='" + AdjustmentNumber + @"'");
                //SqlAdjustment += (@"");
                Adjustment adjustment = this.ScanDataTable(SqlAdjustment).ConvertToEntity <Adjustment>();

                AdjustmentManagementAccessor adjustmentDetail = new AdjustmentManagementAccessor();
                string str = adjustmentDetail.Complets(adjustment.ID, "库存移动单");

                if (str.Contains("提交成功"))
                {
                    return(1);
                }
                else
                {
                    string UpdateadjustmentSql = (@" update WMS_Adjustment set  Status=-1  where AdjustmentNumber='" + AdjustmentNumber + @"' and CustomerID=" + CustomerID);
                    this.ScanDataTable(UpdateadjustmentSql);
                    return(0);
                }
                //return this.ScanExecuteNonQuery(sqlCheck);
                //return dt.ConvertToEntityCollection<Inventorys>();
            }
            catch (Exception ex)
            {
                SysLogWriter.Error("MoveLocation(Dao层)" + Creator + ex.ToString());
            }
            return(0);
        }
Esempio n. 8
0
        public DataSet ScanDataSet(string Sql)
        {
            DataSet       ds   = new DataSet();
            SqlConnection conn = new SqlConnection(BaseAccessor._dataBase.ConnectionString);

            conn.Open();
            SqlTransaction transaction;

            transaction = conn.BeginTransaction();
            try
            {
                SqlCommand cmd = new SqlCommand(Sql, conn);
                cmd.Transaction    = transaction;
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 1800;


                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                sda.Fill(ds);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                SysLogWriter.Error("ScanDataSet 数据库连接" + ex.ToString());
            }
            finally
            {
                conn.Close();
                transaction.Dispose();
            }

            return(ds);
            //MySqlTransaction st = con.BeginTransaction();//启用事务实现

            //MySqlCommand com = con.CreateCommand();

            //com.Transaction = st;

            //try

            //{

            //    com.CommandText = cmd;

            //    com.ExecuteNonQuery();

            //    st.Commit();

            //    return true;

            //}

            //catch

            //{

            //    st.Rollback();

            //    return false;

            //}
        }