Exemple #1
0
        public string UpPallet(IinvdQuery Iinvd, string newinvd, string num, int userId)
        {
         try
            {
                return _palletMove.UpPallet(Iinvd, newinvd, num,userId);
            }
            catch (Exception ex)
            {

                throw new Exception("PalletMoveMgr-->UpPallet" + ex.Message, ex);
            }
        }
Exemple #2
0
        public List<IinvdQuery> GetPalletList(IinvdQuery Iinvd, string invposcat = null)
        {
            try
            {
                return _palletMove.GetPalletList(Iinvd, invposcat);
            }
            catch (Exception ex)
            {

                throw new Exception("PalletMoveMgr-->GetPalletList" + ex.Message, ex);
            }
        }
Exemple #3
0
 /// <summary>
 /// 捕获到主料位,及时更新时间
 /// </summary>
 /// <param name="Iinvd"></param>
 /// <returns></returns>
 public int UpPalletTime(IinvdQuery Iinvd)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"update iinvd set cde_dt='{0}' where  iinvd.row_id='{1}';", Iinvd.cde_dt.ToString("yyyy-MM-dd"), Iinvd.row_id);
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PalletMoveDao-->UpPalletTime-->" + ex.Message + sb.ToString(), ex);
     }
 }
Exemple #4
0
        /// <summary>
        /// 啊啊啊啊
        /// </summary>
        /// <param name="Iinvd"></param>
        /// <returns></returns>
        public int UpPalletTime(IinvdQuery Iinvd)
        { 
         try
            {
                return _palletMove.UpPalletTime(Iinvd);
            }
            catch (Exception ex)
            {

                throw new Exception("PalletMoveMgr-->UpPalletTime" + ex.Message, ex);
            }

        }
Exemple #5
0
        /// <summary>
        /// 通过商品编号和料位编号查询
        /// </summary>
        /// <param name="Iinvd">实体</param>
        /// <returns>因为商品编号和料位是固定的,只能查询出一条,应该返回一个实体,在次返回集合</returns>
        public List<IinvdQuery> GetPalletList(IinvdQuery Iinvd, string invposcat = "")
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendLine(@"select p.product_name,i.row_id,i.lic_plt_id,i.dc_id,i.whse_id,i.po_id,i.plas_id,i.prod_qty,i.rcpt_id,i.lot_no,i.hgt_used,");
                sb.AppendLine(@" i.create_user,i.create_dtim,i.change_user,i.change_dtim,i.cde_dt,i.ista_id as ista_id,i.receipt_dtim,i.stor_ti,i.stor_hi");
                sb.AppendLine(@" ,i.inv_pos_cat,i.qity_id,i.plas_loc_id,i.item_id,i.plas_prdd_id,i.made_date,pe.cde_dt_incr,pe.cde_dt_var,pe.pwy_dte_ctl,ioc.lsta_id as iloc_ista ,ioc.lcat_id,concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as prod_sz,vb.vendor_id from iinvd i ");//把料位锁先映射到库存锁上。主,副料位
                sb.AppendLine(@"  left join product_item pi on i.item_id=pi.item_id ");
                sb.AppendLine(@" left join product p on p.product_id=pi.product_id ");
                sb.AppendLine(@" LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id ");
                sb.AppendLine(@" LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id ");
                sb.AppendLine(@" left join iloc ioc on ioc.loc_id=i.plas_loc_id ");
                sb.AppendLine(@" left join vendor_brand vb on p.brand_id=vb.brand_id ");
                sb.AppendLine(@" left join product_ext pe on pe.item_id=i.item_id ");
                if (Iinvd.item_id != 0)
                {
                    sb.AppendFormat(@"WHERE 1=1 and i.item_id='{0}' ", Iinvd.item_id);
                }
                else
                {
                    sb.AppendLine(@"left JOIN iupc upc on i.item_id=upc.item_id");
                    sb.AppendFormat(@"WHERE 1=1 and upc.upc_id='{0}' ", Iinvd.upc_id);
                }
                sb.AppendFormat(@"and  (i.plas_loc_id='{0}' or ioc.hash_loc_id='{0}') ", Iinvd.plas_loc_id);

                if (!string.IsNullOrEmpty(invposcat))//如果无条件就查询所有。如果有条件就查询副料位的,主料位 S,副料位R
                {
                    sb.AppendFormat(" and ioc.lcat_id='{0}' ", invposcat);
                }
                if (!string.IsNullOrEmpty(Iinvd.ista_id))//如果无条件就查询所有。如果有条件就查询副料位的,主料位 S,副料位R
                {
                    sb.AppendFormat(" and i.ista_id='{0}' ", Iinvd.ista_id);
                }
                sb.AppendFormat(" order by cde_dt");

                return _access.getDataTableForObj<IinvdQuery>(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("PalletMoveDao-->GetPalletList-->" + ex.Message + sb.ToString(), ex);
            }
        }
Exemple #6
0
 public List<IinvdQuery> KucunExport(IinvdQuery nvd)
 {
     try
     {
         return _ivddao.KucunExport(nvd);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->KucunExport-->" + ex.Message, ex);
     }
 }
Exemple #7
0
 public DataTable DifCountBook(IinvdQuery m)
 {
     try
     {
         return _ivddao.DifCountBook(m);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->DifCountBook-->" + ex.Message, ex);
     }
 }
Exemple #8
0
        /// <summary>
        /// 盤點薄報表所用
        /// </summary>
        /// <returns></returns>
        public DataTable CountBookOBK(IinvdQuery m)
        {
            StringBuilder sbSql = new StringBuilder();
            StringBuilder sbWhere = new StringBuilder();
            try
            {
                if (m.startIloc != "")
                {
                    sbWhere.AppendFormat(" and i.plas_loc_id>='{0}' ", m.startIloc);
                }
                if (m.endIloc != "")
                {
                    sbWhere.AppendFormat(" and i.plas_loc_id<='{0}' ", m.endIloc);
                }
                if (m.startcost != 0)
                {//金額
                    sbWhere.AppendFormat(" and ABS(prod_qty-st_qty)* pm.cost>='{0}' ", m.startcost);
                }
                if (m.endcost != 0)
                {
                    sbWhere.AppendFormat(" and ABS(prod_qty-st_qty)* pm.cost <='{0}' ", m.endcost);
                }

                sbSql.AppendFormat(@"
SELECT DISTINCT i.row_id,i.item_id,'' as prod_sz, prod_qty as 'st_qty',st_qty as 'prod_qty',ABS(prod_qty-st_qty)* pm.cost as 'money',CONCAT(v.brand_name,'-',p.product_name) as 'product_name',loc.loc_id,loc.lsta_id,pm.cost,i.made_date,i.cde_dt
 from iinvd i 
LEFT JOIN iloc loc on i.plas_loc_id=loc.loc_id
LEFT JOIN iialg ia ON i.plas_loc_id=ia.loc_id AND i.made_date=ia.made_dt AND i.cde_dt=ia.cde_dt 
LEFT JOIN product_item pi on pi.item_id=i.item_id
LEFT JOIN product p ON pi.product_id=p.product_id
LEFT JOIN vendor_brand v ON p.brand_id=v.brand_id
LEFT JOIN price_master pm on pm.product_id=pi.product_id and pm.site_id='1'
WHERE st_qty=0 AND ia.create_dtim> ADDDATE(NOW(),-3) AND iarc_id='OB' {0} ", sbWhere.ToString());
                //sbSql.AppendFormat(" group by i.row_id");
                DataTable dt = _access.getDataTable(sbSql.ToString());
                return dt;
            }
            catch (Exception ex)
            {
                throw new Exception("IinvdDao-->CountBookOBK-->" + ex.Message + " sql:" + sbSql.ToString(), ex);
            }
        }
Exemple #9
0
 public DataTable PastProductExportExcel(IinvdQuery vd)
 {
     try
     {
         return _ivddao.PastProductExportExcel(vd);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->PastProductExportExcel-->" + ex.Message, ex);
     }
 }
        //理货员工作--寄仓--庫存信息
        public HttpResponseBase GetStockByItemid()
        {
            string json = string.Empty;
            int totalCount = 0;
            int islock = 0;
            _iinvd = new IinvdMgr(mySqlConnectionString);
            IinvdQuery query = new IinvdQuery()
            {
                ista_id = "A"
            };
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["item_id"].ToString().Trim()))
                {
                    query.item_id = Convert.ToUInt32(Request.Params["item_id"].ToString().Trim());
                    List<IinvdQuery> listIinvdQuery = _iinvd.GetIinvdListByItemid(query, out totalCount);
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                    //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                    //timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    timeConverter.DateTimeFormat = "yyyy-MM-dd";
                    if (totalCount > listIinvdQuery.Count)
                    {
                        islock = 1;
                    }
                    //實際能檢的庫存listIinvdQuery.Count
                    if (listIinvdQuery.Count > 0)
                    {
                        json = JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter) ;//返回json數據
                    }
                    else
                    {
                        IinvdQuery m = new IinvdQuery();
                        m.prod_qty = 0;
                        m.made_date = DateTime.Now;
                        m.cde_dt = DateTime.Now;
                        listIinvdQuery.Add(m);
                        json = JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter);//返回json數據
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemple #11
0
        /**
         *僅用於快速結單  
         */
        public int addIialgIstock_AutoMarket(IialgQuery q)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlstr = new StringBuilder();

            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                sql.AppendFormat("select pwy_dte_ctl,cde_dt_incr from product_ext where item_id='{0}';", q.item_id);//查看是否是有效期控管的商品
                DataTable _dtProExt = _access.getDataTable(sql.ToString());
                sql.Clear();
                DateTime cde_dt = q.made_dt;
                sql.AppendFormat("select iinvd.row_id from iinvd  left join iloc on iloc.loc_id=iinvd.plas_loc_id  where iinvd.item_id='{0}' and iinvd.made_date ='{1}' and iloc.lcat_id='S' and iinvd.ista_id='A' ; ", q.item_id, CommonFunction.DateTimeToString(q.made_dt).Substring(0, 10));//查詢此數據未鎖定的

                DataTable _dtIinvd = _access.getDataTable(sql.ToString());
                sql.Clear();
                sql.AppendFormat("select iinvd.row_id from iinvd  left join iloc on iloc.loc_id=iinvd.plas_loc_id  where iinvd.item_id='{0}' and iinvd.made_date ='{1}' and iloc.lcat_id='S' and iinvd.ista_id='H' ; ", q.item_id, CommonFunction.DateTimeToString(q.made_dt).Substring(0, 10));//查詢此數據已鎖定的
                DataTable _Iinvd = _access.getDataTable(sql.ToString());
                sql.Clear();
                sql.AppendFormat("select iinvd.row_id from iinvd left join iloc on iloc.loc_id=iinvd.plas_loc_id where iinvd.item_id='{0}' and iinvd.made_date ='{1}' and iloc.lcat_id='S' and iinvd.ista_id='H' ; ", q.item_id, CommonFunction.DateTimeToString(cde_dt).Substring(0, 10));//查詢今日庫存是否已鎖
                DataTable _TodayIinvd = _access.getDataTable(sql.ToString());
                sql.Clear();
                sql.AppendFormat("select iinvd.row_id from iinvd left join iloc on iloc.loc_id=iinvd.plas_loc_id  where iinvd.item_id='{0}' and iinvd.made_date ='{1}' and iloc.lcat_id='S' and iinvd.ista_id='A' ; ", q.item_id, CommonFunction.DateTimeToString(cde_dt).Substring(0, 10));//查詢今日庫存是否已鎖
                DataTable _dtTodayIinvd = _access.getDataTable(sql.ToString());
                sql.Clear();
                int qty_o = q.qty_o;
                #region 新改
                if (_dtProExt.Rows.Count > 0)//判斷是否有效期控管
                {
                    if (_dtProExt.Rows[0]["pwy_dte_ctl"].ToString().ToUpper().Equals("Y"))/*查询是否是有效期控管的商品*/
                    {
                        cde_dt = q.made_dt.AddDays(Convert.ToInt32(_dtProExt.Rows[0]["cde_dt_incr"]));//有效日期是製造日期加上有效期天數
                    }
                    if (_Iinvd.Rows.Count > 0)//查詢此數據已鎖定的
                    {
                        return 2;//進入的庫存已鎖,不能庫調
                    }
                    else //庫存未鎖
                    {
                        if (_dtIinvd.Rows.Count > 0)//存在此數據
                        {
                            sqlstr.AppendFormat(" update iinvd set prod_qty='{0}',change_user='******',change_dtim='{2}' where row_id='{3}';", q.pnum, q.create_user, CommonFunction.DateTimeToString(DateTime.Now), _dtIinvd.Rows[0][0]);//RF理貨需要的庫存
                            mySqlCmd.CommandText = sqlstr.ToString();
                            mySqlCmd.ExecuteNonQuery();
                            sqlstr.Clear();
                        }
                        else //不存在此數據
                        {
                            qty_o = 0;
                            IinvdQuery ivd = new IinvdQuery();
                            sqlstr.AppendLine(@"insert into iinvd (lic_plt_id,dc_id,whse_id,po_id,plas_id,prod_qty,");
                            sqlstr.AppendLine(@"rcpt_id,lot_no,hgt_used,create_user,create_dtim,");
                            sqlstr.AppendLine(@"change_user,change_dtim,cde_dt,ista_id,receipt_dtim,");
                            sqlstr.AppendLine(@"stor_ti,stor_hi,inv_pos_cat,qity_id,");
                            sqlstr.AppendLine(@"plas_loc_id,item_id,plas_prdd_id,made_date) VALUES (");
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.lic_plt_id, ivd.dc_id, ivd.whse_id, ivd.po_id);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.plas_id, q.pnum - q.qty_o, ivd.rcpt_id, ivd.lot_no);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.hgt_used, q.create_user, CommonFunction.DateTimeToString(DateTime.Now), q.create_user);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", CommonFunction.DateTimeToString(DateTime.Now), CommonFunction.DateTimeToString(cde_dt), "A", CommonFunction.DateTimeToString(ivd.receipt_dtim));
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.stor_ti, ivd.stor_hi, ivd.inv_pos_cat, ivd.qity_id);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}');", q.loc_id.ToString().ToUpper(), q.item_id, ivd.plas_prdd_id, CommonFunction.DateTimeToString(DateTime.Now));
                            mySqlCmd.CommandText = sqlstr.ToString();
                            mySqlCmd.ExecuteNonQuery();
                            sqlstr.Clear();
                        }
                    }
                }
                else //非有效期控管的商品
                {
                    //q.made_dt = DateTime.Now;
                    if (_TodayIinvd.Rows.Count > 0)//非有效期控管的今天的是否鎖上
                    {
                        return 2;
                    }
                    else
                    {
                        if (_dtTodayIinvd.Rows.Count > 0)//有今天上架的了,那就更改
                        {
                            sqlstr.AppendFormat(" update iinvd set prod_qty='{0}',change_user='******',change_dtim='{2}' where row_id='{3}';", q.pnum, q.create_user, CommonFunction.DateTimeToString(DateTime.Now), _dtTodayIinvd.Rows[0][0]);//RF理貨需要的庫存
                            mySqlCmd.CommandText = sqlstr.ToString();
                            mySqlCmd.ExecuteNonQuery();
                            sqlstr.Clear();
                        }
                        else
                        {
                            qty_o = 0;
                            IinvdQuery ivd = new IinvdQuery();
                            sqlstr.AppendLine(@"insert into iinvd (lic_plt_id,dc_id,whse_id,po_id,plas_id,prod_qty,");
                            sqlstr.AppendLine(@"rcpt_id,lot_no,hgt_used,create_user,create_dtim,");
                            sqlstr.AppendLine(@"change_user,change_dtim,cde_dt,ista_id,receipt_dtim,");
                            sqlstr.AppendLine(@"stor_ti,stor_hi,inv_pos_cat,qity_id,");
                            sqlstr.AppendLine(@"plas_loc_id,item_id,plas_prdd_id,made_date) VALUES (");
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.lic_plt_id, ivd.dc_id, ivd.whse_id, ivd.po_id);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.plas_id, q.pnum - q.qty_o, ivd.rcpt_id, ivd.lot_no);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.hgt_used, q.create_user, CommonFunction.DateTimeToString(DateTime.Now), q.create_user);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", CommonFunction.DateTimeToString(DateTime.Now), CommonFunction.DateTimeToString(cde_dt), "A", CommonFunction.DateTimeToString(ivd.receipt_dtim));
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}',", ivd.stor_ti, ivd.stor_hi, ivd.inv_pos_cat, ivd.qity_id);
                            sqlstr.AppendFormat(@"'{0}','{1}','{2}','{3}');", q.loc_id.ToString().ToUpper(), q.item_id, ivd.plas_prdd_id, CommonFunction.DateTimeToString(DateTime.Now));
                            mySqlCmd.CommandText = sqlstr.ToString();
                            mySqlCmd.ExecuteNonQuery();
                            sqlstr.Clear();
                        }
                    }

                }

                #endregion
                sqlstr.Append(@"insert into iialg (loc_id,item_id,iarc_id,qty_o,create_dtim,create_user,doc_no,po_id,made_dt,cde_dt,adj_qty,remarks,c_made_dt,c_cde_dt )values (");
                sqlstr.AppendFormat(" '{0}','{1}','{2}','{3}' ", q.loc_id.ToString().ToUpper(), q.item_id, "PC", qty_o);//qty_o=0;新增的時候
                sqlstr.AppendFormat(" ,'{0}','{1}', '{2}','{3}' ", CommonFunction.DateTimeToString(DateTime.Now), q.create_user, "", "");
                sqlstr.AppendFormat(" ,'{0}','{1}','{2}','{3}'", CommonFunction.DateTimeToString(q.made_dt), CommonFunction.DateTimeToString(cde_dt), q.pnum - q.qty_o, "庫調:" + q.order_id);
                sqlstr.AppendFormat(" ,'{0}','{1}');", CommonFunction.DateTimeToString(q.c_made_dt), CommonFunction.DateTimeToString(q.c_cde_dt));
                mySqlCmd.CommandText = sqlstr.ToString();

                mySqlCmd.ExecuteNonQuery();
                sqlstr.Clear();
                sql.AppendFormat("select sum(prod_qty) as prod_qty from iinvd where item_id='{0}' and ista_id='A'", q.item_id);
                DataTable _dtprod_qty = _access.getDataTable(sql.ToString());
                if (string.IsNullOrEmpty(_dtprod_qty.Rows[0][0].ToString()))
                {
                    _dtprod_qty.Rows[0][0] = 0;
                }
                sql.Clear();
                sqlstr.AppendFormat("insert into istock_change(sc_trans_id,sc_cd_id,item_id,sc_trans_type,sc_num_old,sc_num_chg,sc_num_new,sc_time,sc_user,sc_note,sc_istock_why) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", q.order_id, "", q.item_id, 3, Convert.ToInt32(_dtprod_qty.Rows[0][0]), (q.pnum - q.qty_o), Convert.ToInt32(_dtprod_qty.Rows[0][0]) - q.qty_o + q.pnum, CommonFunction.DateTimeToString(DateTime.Now), q.create_user, "理貨庫調", 4);
                mySqlCmd.CommandText = sqlstr.ToString();

                mySqlCmd.ExecuteNonQuery();
                sqlstr.Clear();
                mySqlCmd.Transaction.Commit();
                return 100;
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception(" IialgDao-->addIialgIstock-->" + ex.Message + sql.ToString(), ex);
            }

        }
Exemple #12
0
 public DataTable GetIinvdCountBook(IinvdQuery m)
 {
     DataTable dt = _ivddao.GetIinvdCountBook(m);
     try
     {
         return dt;
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->GetIinvdCountBook-->" + ex.Message, ex);
     }
 }
Exemple #13
0
        public bool SaveReceiptShelves(IpoNvdQuery invd_query,int pick_num)
        {
            try
            {
                //更新IpoNvd 表
                IpoNvdQuery query = _IpoNvdDao.GetIpoNvd(invd_query);

                query.modify_user = invd_query.modify_user;
                query.made_date = invd_query.made_date;
                query.cde_dt = invd_query.cde_dt;
                query.out_qty = query.out_qty - pick_num;
                query.com_qty = query.com_qty + pick_num;

                if (query.out_qty > 0)
                {
                    query.work_status = "SKP";
                }
                else if (query.out_qty == 0)
                {
                    query.work_status = "COM";
                }
                string UpdateIpoNvdSql = _IpoNvdDao.UpdateIpoNvdSql(query);

                //更新IpoNvdLog表
                IpoNvdLogQuery invdLog = new IpoNvdLogQuery();
                invdLog.work_id = query.work_id;
                invdLog.ipo_id = query.ipo_id;
                invdLog.item_id = (uint)query.item_id;
                invdLog.add_qty = pick_num;
                invdLog.cde_date = query.cde_dt;
                invdLog.made_date = query.made_date;
                invdLog.create_user = query.modify_user;

                string InsertIpoNvdLogSql = _IpoNvdDao.InsertIpoNvdLogSql(invdLog);
                //更新iinvd表
                IinvdQuery iinvd_query = new IinvdQuery();
                iinvd_query.made_date = query.made_date;
                iinvd_query.cde_dt = query.cde_dt;
                iinvd_query.prod_qty = pick_num;
                iinvd_query.ista_id = "A";
                iinvd_query.create_user = invd_query.modify_user;
                iinvd_query.change_user = invd_query.modify_user;
                iinvd_query.plas_loc_id = invd_query.loc_id;
                iinvd_query.item_id = query.item_id;
                string ista_id = string.Empty;
                string UpdateIinvdSql = _iinvdDao.UpdateIinvdSql(iinvd_query, out ista_id);
                
                //更新istockchange表
                IstockChangeQuery stock_query = new IstockChangeQuery();
                stock_query.sc_trans_id = ""; 
                stock_query.sc_cd_id = "";
                stock_query.item_id = query.item_id; 
                stock_query.sc_trans_type = 1; 
                stock_query.sc_num_chg = pick_num;
                stock_query.sc_time = DateTime.Now;
                stock_query.sc_user = invd_query.modify_user;
                stock_query.sc_note = "收貨上架";
                stock_query.sc_istock_why = 4;
                string insertIstockChangeSql = string.Empty;
                if (ista_id != "H")
                {
                    insertIstockChangeSql = istockchangeDao.insertIstockChangeSql(stock_query);
                }

                //執行SQL
                ArrayList arrList = new ArrayList();
                arrList.Add(UpdateIpoNvdSql);
                arrList.Add(InsertIpoNvdLogSql);
                arrList.Add(UpdateIinvdSql);
                if (ista_id != "H")
                {
                    arrList.Add(insertIstockChangeSql);
                }

                bool result = myDao.ExcuteSqls(arrList);
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("IpoNvdMgr-->SaveReceiptShelves-->" + ex.Message, ex);
            }
        }
Exemple #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Iinvd">通過實體查詢源料位的列表信息</param>
        /// <param name="newinvd">同夥參數查詢目標料位的列表信息</param>
        /// <param name="num">截取要轉移的數量</param>
        /// <param name="userId">新增-修改人</param>
        /// <returns></returns>
        public string UpPallet(IinvdQuery Iinvd, string newinvd, string num,int userId)
        {
            StringBuilder sb = new StringBuilder();
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            int result = 0;
            newinvd = newinvd.ToUpper();
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                ///先通过实体查询副料位
                List<IinvdQuery> SIinvd = new List<IinvdQuery>();//副料位
                SIinvd = new PalletMoveDao(connStr).GetPalletList(Iinvd);
             
                sb.Clear();
                #region 再获取修改数量的数组

                int[] sort = new int[SIinvd.Count];
                if (string.IsNullOrEmpty(num))//免得再次加載時直接點轉移
                {
                    return "2";
                }
                // string arr = "Request.Params[]";//获取的row_id/number,row_id/number
                string[] nums = num.Split(',');//拆分row_id/number
                for (int m = 0; m < SIinvd.Count; m++)
                {
                    sort[m] = 0;
                    for (int n = 0; n < nums.Length; n++)
                    {
                        string[] xiu = nums[n].Split('/');
                        string id = xiu[0];//row_Id
                        string shu = xiu[1];//number
                        if (SIinvd[m].row_id == int.Parse(id))
                        {
                            sort[m] = int.Parse(xiu[1]);
                        }
                    }
                }
                #endregion

                List<IinvdQuery> PIinvd = new List<IinvdQuery>();//目的料位

                #region 测试
                mySqlCmd.CommandText = string.Format("select lsta_id  from iloc where loc_id='{0}';", newinvd);
                object serchlsta = mySqlCmd.ExecuteScalar();//目标料位--锁定状态
                sb.Clear();

                mySqlCmd.CommandText = string.Format("select lcat_id  from iloc where loc_id='{0}';", newinvd);
                object serchlcat = mySqlCmd.ExecuteScalar();//目标料位--主副料位
                sb.Clear();

                if (string.IsNullOrEmpty(newinvd) || serchlsta == null || serchlcat==null)//查看目标料位是否存在
                    return "7";//目标料位不存在
                Iinvd.plas_loc_id = newinvd;
                PIinvd = new PalletMoveDao(connStr).GetPalletList(Iinvd);
              
                if (SIinvd[0].plas_loc_id == newinvd)//原料位和目的料位相同
                {
                    return "5";//源料位和副料位相同
                }
                if (SIinvd[0].iloc_ista == "H")//如果源料位的料位锁住,不可补货到目标料位
                {
                    return "6";//源料位被锁
                }
              
                if ( serchlsta.ToString() == "H")//如果目标料锁住,不可收货
                {
                    return "8";//目标料位被锁
                }
                mySqlCmd.CommandText = string.Format("select count(*)from iinvd INNER JOIN iloc on iinvd.plas_loc_id=iloc.loc_id where iinvd.plas_loc_id='{0}';", newinvd);//目标料位是否被释放
                int IsEmpty = int.Parse(mySqlCmd.ExecuteScalar().ToString());
                sb.Clear();
                uint itemId = 0;
                if ( serchlcat.ToString().Equals("S") && serchlsta.ToString() == "A" )//如果目標料位是主料位
                {
                    mySqlCmd.CommandText = string.Format("select iplas.item_id from iloc left join  iplas on iloc.loc_id=iplas.loc_id where iloc.loc_id='{0}' ;", newinvd);//如果目标料位是主料位,查询主料位所指定的商品
                    itemId = uint.Parse(mySqlCmd.ExecuteScalar().ToString());
                    sb.Clear();
                }
                if (serchlcat.ToString().Equals("S") && SIinvd[0].item_id != itemId)//目标主料位,非商品主料位
                {
                    return "4";//目标料位非商品主料位
                }
                //到副料位《被释放的》---//目标料位本来就有商品--//到主料位《是这个商品的主料位》
                if ( serchlcat.ToString().Equals("R") && IsEmpty <= 0 || PIinvd.Count > 0 || itemId == SIinvd[0].item_id)
                {
                    for (int m = 0; m < sort.Length; m++)//先循环副料位表,
                    {
                        int a = SIinvd[m].cde_dt.CompareTo(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")));
                        if (sort[m] == 0)//如果数据为零,不修改
                            continue;
                        bool blag = true;

                        #region 循環目的料位,找到時間相同 的就進行修改

                        for (int n = 0; n < PIinvd.Count; n++)//循环目的料位进行比较
                        {
                            if (SIinvd[m].cde_dt.ToString("yyyy-MM-dd") == PIinvd[n].cde_dt.ToString("yyyy-MM-dd"))//时间相同 修改
                            {
                                if (SIinvd[m].prod_qty < sort[m])//判断转移的数量是否符合
                                {
                                    return "0";
                                }
                                blag = false;
                                SIinvd[m].prod_qty = SIinvd[m].prod_qty - sort[m];
                                PIinvd[n].prod_qty = PIinvd[n].prod_qty + sort[m];
                                //change_dtim,create_user,change_user
                                sb.AppendFormat("update iinvd set prod_qty='{0}' ,change_dtim='{1}', change_user='******' ", SIinvd[m].prod_qty, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), userId);//修改原料位数量 减
                                sb.AppendFormat("  where  iinvd.row_id='{0}';", SIinvd[m].row_id);
                                mySqlCmd.CommandText = sb.ToString();
                                result += mySqlCmd.ExecuteNonQuery();
                                sb.Clear();
                                sb.AppendFormat("update iinvd set prod_qty='{0}' ,change_dtim='{1}', change_user='******' ", PIinvd[n].prod_qty, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), userId);//修改目标料位 加 
                                if (SIinvd[m].ista_id == "H")//如果源料位上锁,修改到目标料位时,加上上锁原因。
                                {
                                    sb.AppendFormat(" ,ista_id='{0}',qity_id='{1}' ", SIinvd[m].ista_id, SIinvd[m].qity_id);
                                }
                                sb.AppendFormat(" where  iinvd.row_id='{0}';", PIinvd[n].row_id);
                                mySqlCmd.CommandText = sb.ToString();
                                result += mySqlCmd.ExecuteNonQuery();
                                sb.Clear();
                                break;//如果目标料位两个时间相同,那就捕货到第一个符合的料位,到第二个跳出此次循环
                            }
                        }
                        #endregion

                        #region 目的料位找不到的進行新增
                        if (blag)//时间不同的话,新增至目标料位
                        {
                            if (SIinvd[m].prod_qty < sort[m])//判断转移的数量是否符合
                            {
                                return "0";
                            }
                            uint id = SIinvd[m].item_id;
                            SIinvd[m].prod_qty = SIinvd[m].prod_qty - sort[m];

                            sb.Append("set sql_safe_updates = 0;");
                            sb.AppendFormat("update iinvd set prod_qty='{0}' ,change_dtim='{1}' ,change_user='******' ", SIinvd[m].prod_qty, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), userId);//修改原料位数量 减
                            sb.AppendFormat("  where  row_id='{0}';", SIinvd[m].row_id);
                            sb.Append("set sql_safe_updates = 1;");
                            mySqlCmd.CommandText = sb.ToString();
                            result += mySqlCmd.ExecuteNonQuery();
                            sb.Clear();
                            sb.AppendLine(@"insert into iinvd (lic_plt_id,dc_id,whse_id,po_id,plas_id,prod_qty,");
                            sb.AppendLine(@"rcpt_id,lot_no,hgt_used,create_user,create_dtim,");
                            sb.AppendLine(@"change_user,change_dtim,cde_dt,ista_id,receipt_dtim,");
                            sb.AppendLine(@"stor_ti,stor_hi,inv_pos_cat,qity_id,");
                            sb.AppendLine(@"plas_loc_id,item_id,plas_prdd_id,made_date) VALUES (");
                            sb.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}','{5}',", SIinvd[m].lic_plt_id, SIinvd[m].dc_id, SIinvd[m].whse_id, SIinvd[m].po_id,SIinvd[m].plas_id, sort[m]);
                            sb.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", SIinvd[m].rcpt_id, SIinvd[m].lot_no, SIinvd[m].hgt_used, userId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            sb.AppendFormat(@"'{0}','{1}','{2}','{3}','{4}',", userId,DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SIinvd[m].cde_dt.ToString("yyyy-MM-dd"), SIinvd[m].ista_id, SIinvd[m].receipt_dtim.ToString("yyyy-MM-dd HH:mm:ss")); 
                            sb.AppendFormat(@"'{0}','{1}','{2}','{3}',", SIinvd[m].stor_ti, SIinvd[m].stor_hi, SIinvd[m].inv_pos_cat, SIinvd[m].qity_id);
                            sb.AppendFormat(@"'{0}','{1}','{2}','{3}');", newinvd, SIinvd[m].item_id, SIinvd[m].plas_prdd_id,SIinvd[m].made_date.ToString("yyyy-MM-dd"));
                            mySqlCmd.CommandText = sb.ToString();
                            result += mySqlCmd.ExecuteNonQuery();
                            sb.Clear();
                        }
                        #endregion
                    }
                    if (PIinvd.Count == 0 && serchlcat.Equals("R"))//这个副料位没有被使用过,,主料位不需要更改
                    {
                        sb.Append("set sql_safe_updates = 0;");
                        sb.AppendFormat("update iloc set lsta_id='A' where loc_id='{0}';", newinvd);//释放过的副料位,增加别的商品,要把状态改为已启用
                        sb.Append("set sql_safe_updates = 1;");
                        mySqlCmd.CommandText = sb.ToString();
                        result += mySqlCmd.ExecuteNonQuery();
                        sb.Clear();
                    }
                    sb.Append("set sql_safe_updates = 0;");
                    sb.AppendFormat("DELETE from iinvd where  prod_qty='{0}' and plas_loc_id='{1}';", 0, SIinvd[0].plas_loc_id.ToString().ToUpper());//刪除源料位 库存为零的信息
                    sb.Append("set sql_safe_updates = 1;");
                    mySqlCmd.CommandText = sb.ToString();
                    result += mySqlCmd.ExecuteNonQuery();
                    sb.Clear();
                    sb.AppendFormat("select count(*)from iinvd where  plas_loc_id='{0}' ;", SIinvd[0].plas_loc_id.ToUpper());
                    mySqlCmd.CommandText = sb.ToString();
                    if (int.Parse(mySqlCmd.ExecuteScalar().ToString()) == 0 && SIinvd[0].lcat_id == "R")//副料位的库存都空了,修改料位已占用为可以使用。F 可以使用,H锁住,A已占用
                    {
                        sb.Append("set sql_safe_updates = 0;");
                        sb.AppendFormat("update iloc set lsta_id='F' where loc_id='{0}';", SIinvd[0].plas_loc_id);// 库存为零的,释放源料位
                        sb.Append("set sql_safe_updates = 1;");
                        mySqlCmd.CommandText = sb.ToString();
                        result += mySqlCmd.ExecuteNonQuery();
                        sb.Clear();
                    }
                }
                else
                {
                    return "1";
                }
                if (result == 0)//代表没有输入数量,所有sql都不会执行
                    return "2";

                mySqlCmd.Transaction.Commit();
                return "3";

                #endregion
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("PalletMoveDao-->UpPallet-->" + ex.Message + sb.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }
Exemple #15
0
 public string remark(IinvdQuery q)
 {
     try
     {
         return _ivddao.remark(q);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->GetIinvdExprotList-->" + ex.Message, ex);
     }
 }
Exemple #16
0
        public bool RFAutoMarketTally(int seld_id)
        {
            int totalCount = 0;
            List<string> iinvd;
            List<string> pick;
            bool markettally = false;
            try
            {
                //根據seld_id獲取aseld記錄信息;
                AseldQuery query_ase = new AseldQuery();
                query_ase.seld_id = seld_id;
                List<AseldQuery> ase = _aseldDao.GetAllAseldList(query_ase, out totalCount);
                if (ase.Count == 1)
                {
                }
                else
                {
                    return false;
                }

                //根據item_id獲取庫存信息;
                IinvdQuery query_ivd = new IinvdQuery()
                {
                    ista_id = "A"
                };
                query_ivd.item_id = ase[0].item_id;
                int out_qty = ase[0].out_qty;
                if (out_qty < 0)
                {
                    return false;
                }
                List<IinvdQuery> store_ivd = GetIinvdListByItemid(query_ivd, out totalCount);
                int stocksum = GetStockSum(store_ivd, out_qty, out iinvd, out pick);
                //if (ase[0].sel_loc == "YY999999")
                //{
                //    //沒有主料位,記庫存帳卡
                //    //結單
                //    bool markettally = GETMarkTallyWD(ase[0], stocksum, iinvd.ToArray(), pick.ToArray());
                //}
                if (stocksum < out_qty)
                {
                    //庫調
                    int result = RFKT(ase[0], store_ivd[0], out_qty - stocksum + store_ivd[0].prod_qty);
                    if (result == 100)
                    {
                        //刷新庫存信息
                        store_ivd = GetIinvdListByItemid(query_ivd, out totalCount);
                        stocksum = GetStockSum(store_ivd, out_qty, out iinvd, out pick);
                        if (stocksum <= out_qty)
                        {
                            //結單
                            markettally = GETMarkTallyWD(ase[0], stocksum, iinvd.ToArray(), pick.ToArray());
                        }
                        else
                        {
                            markettally = false;
                        }
                    }
                    else
                    {
                        //庫調失敗
                        markettally = false;
                    }
                }
                else if (stocksum >= out_qty)
                {
                    //結單
                    markettally = GETMarkTallyWD(ase[0], out_qty, iinvd.ToArray(), pick.ToArray());
                }
                else
                {
                    markettally = false;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("MarketTallyMgr-->RFAutoMarketTally" + ex.Message, ex);
            }

            return markettally;
        }
Exemple #17
0
        public int RFKT(AseldQuery ase, IinvdQuery ivd,int pnum)
        {
            string json = string.Empty;
            int result = 0;
            IialgQuery q = new IialgQuery();
            uint id = 0; DateTime dt = new DateTime(); int sun = 0;
            _proditemMgr = new ProductItemMgr(mySqlConnectionString);
            ProductItem Proitems = new ProductItem();

            try
            {
                {//商品id
                    q.item_id = ase.item_id;
                    Proitems.Item_Id = ase.item_id;
                }
                // (DateTime.TryParse(Request.Params["made_date"].ToString(), out dt))
                {//商品製造日期
                    //q.made_dt = ivd.made_date;
                    q.made_dt = new DateTime(3000,1,1);
                }
                //if (int.TryParse(Request.Params["prod_qty"].ToString(), out sun))
                {//商品原有數量
                    q.qty_o = ivd.prod_qty;
                }
                //if (int.TryParse(Request.Params["pnum"].ToString(), out sun))
                {//商品撿貨數量
                    q.pnum = pnum;
                }
                //if (!string.IsNullOrEmpty(Request.Params["loc_id"].ToString()))
                {//商品撿貨數量
                    q.loc_id = ase.sel_loc;
                }
                //if (!string.IsNullOrEmpty(Request.Params["order_id"]))
                {
                    q.order_id = ase.ord_id.ToString();
                }
                q.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                //進行庫調
                _iagDao = new IialgDao(mySqlConnectionString);
                Caller call = new Caller();
                call = (System.Web.HttpContext.Current.Session["caller"] as Caller);
                string path = "/WareHouse/KutiaoAddorReduce";
                //if (q.loc_id == "YY999999") 無主料位時也進行庫調
                if (false)
                {
                    json = "{success:false}";
                }
                else
                {
                    Proitems.Item_Stock = q.pnum - q.qty_o;
                    result = _iagDao.addIialgIstock_AutoMarket(q);
                    if (result == 2)
                    {
                        json = "{success:true,msg:2}";
                    }
                    if (result == 100)
                    {
                        //_proditemMgr.UpdateItemStock(Proitems, path, call);
                        json = "{success:true,msg:100}";
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("MarketTallyMgr-->RFKT-->" + ex.Message, ex);
            }
            return result;
        }
Exemple #18
0
 private List<IinvdQuery> GetIinvdListByItemid(IinvdQuery query_ivd, out int totalCount)
 {
     try
     {
         List<IinvdQuery> store_ivd = _ivddao.GetIinvdListByItemid(query_ivd, out totalCount);
         if (store_ivd.Count == 0)
         {
             IinvdQuery m = new IinvdQuery();
             m.prod_qty = 0;
             m.made_date = DateTime.Now;
             m.cde_dt = DateTime.Now;
             store_ivd.Add(m);
         }
         return store_ivd;
     }
     catch (Exception ex)
     {
         throw new Exception("MarketTallyMgr-->GetIinvdListByItemid" + ex.Message, ex);
     }
 }
Exemple #19
0
 public DataTable CountBookOBK(IinvdQuery m)
 {
     try
     {
         return _ivddao.CountBookOBK(m);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->CountBookOBK-->" + ex.Message, ex);
     }
 }
Exemple #20
0
 public int GetIinvdCount(IinvdQuery iinvd)
 {
     try
     {
         return _ivddao.GetIinvdCount(iinvd);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->GetIinvdCount-->" + ex.Message, ex);
     }
 }
Exemple #21
0
 public List<IinvdQuery> GetIinvdExprotList(IinvdQuery ivd)
 {
     try
     {
         if (!string.IsNullOrEmpty(ivd.serchcontent))
         {
             switch (ivd.serch_type)
             {
                 case 1:
                     ivd.serchcontent = _iplasdao.Getlocid(ivd.serchcontent.ToString());
                     break;
                 case 2:
                     ivd.serchcontent = _iplasdao.Getprodbyupc(ivd.serchcontent.ToString()).Rows[0]["item_id"].ToString();
                     break;
                 default:
                     break;
             }
         }
         return _ivddao.GetIinvdExprotList(ivd);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->GetIinvdExprotList-->" + ex.Message, ex);
     }
 }
Exemple #22
0
 public int GetIinvdItemId(IinvdQuery vd)
 {
     StringBuilder sql = new StringBuilder();
     int result = 0;
     try
     {
         sql.AppendFormat(@"SELECT prod_qty FROM iinvd WHERE plas_loc_id='{0}' ", vd.loc_id.ToString().ToUpper());
         if (_dbAccess.getDataTable(sql.ToString()).Rows.Count > 0)
         {
             result = Convert.ToInt32(_dbAccess.getDataTable(sql.ToString()).Rows[0]["prod_qty"]);
         }
         else
         {
             result = 0;//當iinvd表中不存在數據時,iplas表可以刪除
         }
         return result;
     }
     catch (Exception ex)
     {
         throw new Exception("IplasDao-->GetIinvdItemId-->" + ex.Message + sql.ToString(), ex); 
     }
 }
Exemple #23
0
 public DataTable getproduct(IinvdQuery m)
 {
     DataTable dt = _ivddao.getproduct(m);
     try
     {
         return dt;
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->getproduct-->" + ex.Message, ex);
     }
 }
Exemple #24
0
 public int updatemadedate(IinvdQuery Iinvd)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat(" update iinvd set made_date='{0}',cde_dt='{1}',change_user='******',change_dtim='{3}' where row_id='{4}' ", Common.CommonFunction.DateTimeToString(Iinvd.made_date),Common.CommonFunction.DateTimeToString(Iinvd.cde_dt),Iinvd.change_user,Common.CommonFunction.DateTimeToString(DateTime.Now), Iinvd.row_id);
     try
     {
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PalletMoveDao-->updatemadedate-->" + ex.Message + sql.ToString(), ex);
     }
 }
Exemple #25
0
 public int SaveIinvd(IinvdQuery query)
 {
     try
     {
         return _ivddao.SaveIinvd(query);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->SaveIinvd-->" + ex.Message, ex);
     }
 }
Exemple #26
0
        public int UpdateordeleteIinvd(IinvdQuery invd, IinvdQuery newinvd)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("  update iinvd set change_user='******',change_dtim='{1}',prod_qty='{2}' where row_id='{3}'; ", newinvd.change_user, CommonFunction.DateTimeToString(newinvd.change_dtim), newinvd.prod_qty, newinvd.row_id);
            sb.AppendFormat(" delete from iinvd where row_id='{0}'; ", invd.row_id);
            int result = 0;

            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr); 
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;

                mySqlCmd.CommandText = sb.ToString();
                result = mySqlCmd.ExecuteNonQuery();
                mySqlCmd.Transaction.Commit();
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("IialgDao.UpdateordeleteIinvd-->" + ex.Message + sb.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return result;
        }
Exemple #27
0
 public DataTable getVentory(IinvdQuery m)
 {
     try
     {
         return _ivddao.getVentory(m);
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdMgr-->getVentory-->" + ex.Message, ex);
     }
 }
Exemple #28
0
 public int selectcount(IinvdQuery invd)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat(@"select count(*) from iinvd where item_id='{0}' and plas_loc_id='{1}' and made_date='{2}' and cde_dt='{3}' and row_id <> '{4}' ", invd.item_id, invd.plas_loc_id, CommonFunction.DateTimeToString(invd.made_date), CommonFunction.DateTimeToString(invd.cde_dt),invd.row_id);
     try
     {
         return Convert.ToInt32(_access.getDataTable(sql.ToString()).Rows[0][0]);
     }
     catch (Exception ex)
     {
         throw new Exception("PalletMoveDao-->selectcount-->" + ex.Message + sql.ToString(), ex);
     }
 }
        public HttpResponseBase aboutmadetime()
        {
            string jsonStr = string.Empty;
            int result = 0;
            DataTable dt = new DataTable();
            try
            {
                int userId = (Session["caller"] as Caller).user_id;
                DateTime nowtimes = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                int type_id = 0;//類型
                int days = 0;
                int row_id = int.Parse(Request.Params["row_id"]);
                string cde_dtormade_dt = Request.Params["cde_dtormade_dt"];

                string y_cde_dtormade_dt = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["y_cde_dtormade_dt"]))
                {
                    y_cde_dtormade_dt = Request.Params["y_cde_dtormade_dt"];//原來的日期
                }
                if (!string.IsNullOrEmpty(Request.Params["type_id"]))
                {
                    type_id = Convert.ToInt32(Request.Params["type_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["datetimeday"]))
                {
                    days = Convert.ToInt32(Request.Params["datetimeday"]);
                }

                IinvdQuery invd = new IinvdQuery();
                IinvdQuery newinvd = new IinvdQuery();
                IialgQuery ialg = new IialgQuery();
                newinvd.change_user = userId;
                newinvd.change_dtim = DateTime.Now;
                if (!string.IsNullOrEmpty(Request.Params["sloc_id"]))
                {
                    invd.plas_loc_id = Convert.ToString(Request.Params["sloc_id"]).ToUpper();
                    ialg.loc_id = invd.plas_loc_id;
                }
                if (!string.IsNullOrEmpty(Request.Params["prod_id"]))
                {
                    invd.item_id = Convert.ToUInt32(Request.Params["prod_id"]);
                    ialg.item_id = invd.item_id;
                }
                if (!string.IsNullOrEmpty(Request.Params["prod_qtys"]))
                {
                    invd.prod_qty = Convert.ToInt32(Request.Params["prod_qtys"]);
                    ialg.qty_o = invd.prod_qty;
                }
                if (!string.IsNullOrEmpty(Request.Params["remarks"]))
                {
                    invd.remarks = Request.Params["remarks"];
                    ialg.remarks = invd.remarks;
                }
                if (!string.IsNullOrEmpty(Request.Params["po_id"]))
                {
                    ialg.po_id = Request.Params["po_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["iarc_id"]))
                {
                    ialg.iarc_id = Request.Params["iarc_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["doc_no"]))
                {
                    ialg.doc_no = Request.Params["doc_no"];
                }
                ialg.create_user = userId;
                invd.change_user = userId;
                ialg.create_dtim = DateTime.Now;
                invd.change_dtim = DateTime.Now;
                invd.row_id = row_id;
                if (type_id == 1)//表示編輯的是製造日期
                {
                    invd.made_date = DateTime.Parse(cde_dtormade_dt);
                    invd.cde_dt = invd.made_date.AddDays(days);//有效日期
                    if (invd.made_date > nowtimes)//已經過期
                    {
                        jsonStr = "{success:true,msg:1}";//1表示有效日期不能小於當前日期
                    }
                    else
                    {
                        _ipalet = new PalletMoveMgr(mySqlConnectionString);
                        _iialgMgr = new IialgMgr(mySqlConnectionString);
                        result = _ipalet.selectcount(invd);
                        #region 往iialg表中插入時間修改記錄
                        ialg.made_dt = DateTime.Parse(y_cde_dtormade_dt);//原來的日期
                        ialg.c_made_dt = DateTime.Parse(cde_dtormade_dt);//改后的日期
                        ialg.cde_dt = DateTime.Parse(y_cde_dtormade_dt).AddDays(days);//原來的有效日期
                        ialg.c_cde_dt = DateTime.Parse(cde_dtormade_dt).AddDays(days);//修改后的有效日期
                        ialg.adj_qty = 0;
                        if (string.IsNullOrEmpty(ialg.iarc_id))
                        {
                            ialg.iarc_id = "PC";
                        }
                        _iialgMgr.insertiialg(ialg);//往iialg中插入數據,用來記錄數據
                        #endregion
                        if (result > 0)//大於0表示裡面存在一樣子的值
                        {
                            dt = _ipalet.selectrow_id(invd);//獲取這個重複的row_id
                            newinvd.row_id = Convert.ToInt32(dt.Rows[0][0]);
                            newinvd.prod_qty = Convert.ToInt32(dt.Rows[0][1]) + invd.prod_qty;

                            if (_ipalet.UpdateordeleteIinvd(invd, newinvd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                        else
                        {
                            if (_ipalet.updatemadedate(invd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                    }
                }
                else if (type_id == 2)//表示有效日期
                {
                    invd.cde_dt = DateTime.Parse(cde_dtormade_dt);
                    invd.made_date = invd.cde_dt.AddDays(days * (-1));
                    if (invd.made_date > nowtimes)
                    {
                        jsonStr = "{success:true,msg:1}";//1表示有效日期不能小於當前日期
                    }
                    else
                    {
                        _ipalet = new PalletMoveMgr(mySqlConnectionString);
                        _iialgMgr = new IialgMgr(mySqlConnectionString);
                        result = _ipalet.selectcount(invd);
                        #region 往iialg表中插入時間修改記錄
                        ialg.cde_dt = DateTime.Parse(y_cde_dtormade_dt);//原來的有效日期日期
                        ialg.c_cde_dt = DateTime.Parse(cde_dtormade_dt);//改后的有效日期日期
                        ialg.made_dt = DateTime.Parse(y_cde_dtormade_dt).AddDays(days * (-1));//原來的製造日期
                        ialg.c_made_dt = DateTime.Parse(cde_dtormade_dt).AddDays(days * (-1));//修改后製造日期
                        ialg.adj_qty = 0;
                        if (string.IsNullOrEmpty(ialg.iarc_id))
                        {
                            ialg.iarc_id = "PC";
                        }
                        _iialgMgr.insertiialg(ialg);//往iialg中插入數據,用來記錄數據
                        #endregion
                        if (result > 0)//大於0表示裡面存在一樣子的值
                        {
                            dt = _ipalet.selectrow_id(invd);//獲取這個重複的row_id
                            newinvd.row_id = Convert.ToInt32(dt.Rows[0][0]);
                            newinvd.prod_qty = Convert.ToInt32(dt.Rows[0][1]) + invd.prod_qty;
                            if (_ipalet.UpdateordeleteIinvd(invd, newinvd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                        else
                        {
                            if (_ipalet.updatemadedate(invd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Exemple #30
0
 public DataTable selectrow_id(IinvdQuery invd)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat(@"select row_id,prod_qty from iinvd where item_id='{0}' and plas_loc_id='{1}' and made_date='{2}' and cde_dt='{3}' ", invd.item_id, invd.plas_loc_id, CommonFunction.DateTimeToString(invd.made_date), CommonFunction.DateTimeToString(invd.cde_dt));
     try
     {
         return _access.getDataTable(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PalletMoveDao-->selectrow_id-->" + ex.Message + sql.ToString(), ex);
     }
 }