public List<IialgQuery> GetExportIialgList(IialgQuery q) { try { return _iagDao.GetExportIialgList(q); } catch (Exception ex) { throw new Exception("IialgMgr-->GetExportIialgList-->" + ex.Message, ex); } }
public int addIialgIstock(IialgQuery q) { try { return _iagDao.addIialgIstock(q); } catch (Exception ex) { throw new Exception("IialgMgr-->addIialgIstock-->" + ex.Message, ex); } }
public List<IialgQuery> GetIialgList(IialgQuery q, out int totalCount) { try { return _iagDao.GetIialgList(q, out totalCount); } catch (Exception ex) { throw new Exception("IialgMgr-->GetIialgList-->" + ex.Message, ex); } }
public int insertiialg(IialgQuery q) { StringBuilder sql = new StringBuilder(); try {//適當進行修改 sql.AppendFormat(@"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 ('{0}','{1}','{2}','{3}','{4}','{5}', '{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}') ",q.loc_id.ToString().ToUpper(),q.item_id,q.iarc_id,q.qty_o, CommonFunction.DateTimeToString(q.create_dtim),q.create_user, q.doc_no,q.po_id, CommonFunction.DateTimeToString(q.made_dt),CommonFunction.DateTimeToString(q.cde_dt),q.adj_qty,q.remarks,CommonFunction.DateTimeToString(q.c_made_dt),CommonFunction.DateTimeToString(q.c_cde_dt)); return _access.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception(" IialgDao-->insertiialg-->" + ex.Message + sql.ToString(), ex); } }
public int UpdateIinvdLock(Iinvd i,IialgQuery q) { try { IstockChange m = new IstockChange(); m.item_id = GetIinvd(i).FirstOrDefault().item_id; m.sc_trans_type = 1; m.sc_num_old = GetProqtyByItemid(int.Parse(m.item_id.ToString())); m.sc_num_chg = GetIinvd(i).FirstOrDefault().prod_qty; if (i.ista_id=="H") { m.sc_num_chg = -m.sc_num_chg; } m.sc_num_new = m.sc_num_old + m.sc_num_chg; m.sc_time = i.change_dtim; m.sc_user = i.change_user; m.sc_trans_id = q.po_id; m.sc_note = q.remarks; m.sc_istock_why = 1; if (_istockdao.insert(m) > 0) { return _ivddao.UpdateIinvdLock(i); } else { return 0; } } catch (Exception ex) { throw new Exception("IinvdMgr-->UpdateIinvdLock-->" + ex.Message, ex); } }
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; }
/** *僅用於快速結單 */ 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); } }
public int HuiruInsertiialg(System.Data.DataRow[] dr, out int iialgtotal, out int iinvdtotal) { int result = 0; iialgtotal = 0; iinvdtotal = 0; DataTable dt = new DataTable(); Iinvd invd = new Iinvd(); IialgQuery ialg = new IialgQuery(); StringBuilder sb = new StringBuilder(); StringBuilder invdsb = new StringBuilder(); StringBuilder ialgsb = new StringBuilder(); ialg.doc_no = "K" + DateTime.Now.ToString("yyyyMMddHHmmss");//庫調單號 for (int i = 1; i < dr.Length; i++) { string row_id = string.Empty; row_id = dr[i][0].ToString().Trim(); if (!string.IsNullOrEmpty(row_id)) { invd.row_id = int.Parse(dr[i][0].ToString().Trim()); invd.prod_qty = int.Parse(dr[i][5].ToString().Trim()); invdsb.AppendFormat(" update iinvd set prod_qty ='{0}' where row_id='{1}'; ", invd.prod_qty, invd.row_id); iialgtotal++; if (!string.IsNullOrEmpty(dr[i][4].ToString().Trim()))//當存在復盤值時 { ialg.row_id = int.Parse(dr[i][0].ToString().Trim()); ialg.qty_o = int.Parse(dr[i][5].ToString().Trim()); ialg.adj_qty = int.Parse(dr[i][4].ToString().Trim()) - int.Parse(dr[i][5].ToString().Trim()); ialg.loc_id = dr[i][1].ToString().Trim(); ialg.item_id = Convert.ToUInt32(dr[i][3].ToString().Trim()); if (!string.IsNullOrEmpty(dr[i][10].ToString().Trim())) { ialg.made_dttostr = dr[i][10].ToString().Trim(); } if (!string.IsNullOrEmpty(dr[i][11].ToString().Trim())) { ialg.cde_dttostr = dr[i][11].ToString().Trim(); } ialg.create_dtim = DateTime.Now; ialg.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; ialg.iarc_id = "PC"; ialg.po_id = string.Empty; ialgsb.AppendFormat(@"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) values ('{0}','{1}','{2}','{3}', '{4}','{5}', '{6}','{7}','{8}','{9}','{10}'); ", ialg.loc_id, ialg.item_id, ialg.iarc_id, ialg.qty_o, CommonFunction.DateTimeToString(ialg.create_dtim), ialg.create_user, ialg.doc_no, ialg.po_id, ialg.made_dttostr, ialg.cde_dttostr, ialg.adj_qty); iinvdtotal++; } } } sb.AppendFormat(invdsb.ToString()+ialgsb.ToString()); 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.HuiruInsertiialg-->" + ex.Message + sb.ToString(), ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return result; }
public List<IialgQuery> GetExportIialgList(IialgQuery q) { StringBuilder sql = new StringBuilder(); try { sql.Append(@"select ia.doc_no,ia.row_id, ip.loc_id,ia.loc_id as loc_R,ia.item_id,p.product_name,concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as prod_sz ,ia.made_dt,ia.cde_dt,ia.qty_o,ia.adj_qty,ia.iarc_id,ia.create_dtim ,m.user_username AS name,ia.po_id,ia.remarks,ia.c_made_dt,ia.c_cde_dt from iialg ia left join product_item pi on ia.item_id=pi.item_id left join product p on p.product_id=pi.product_id LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id LEFT JOIN iinvd i on ia.item_id = i.item_id AND ia.made_dt=i.made_date AND ia.loc_id=i.plas_loc_id LEFT JOIN iplas ip on ia.item_id = ip.item_id LEFT JOIN manage_user m ON ia.create_user=m.user_id where 1=1"); if (q.item_id > 0) { sql.AppendFormat(" and ia.item_id='{0}' ", q.item_id); } if (!string.IsNullOrEmpty(q.loc_id)) { sql.AppendFormat(" and ia.loc_id='{0}' ", q.loc_id); } if (!string.IsNullOrEmpty(q.po_id)) { sql.AppendFormat(" and ia.po_id='{0}' ", q.po_id); } //if (q.iarc_id.ToString() != "0") //{ // sql.AppendFormat(" and iarc_id='{0}' ", q.iarc_id); //} if (q.starttime > DateTime.MinValue) { sql.AppendFormat(" and ia.create_dtim>='{0}' ", q.starttime.ToString("yyyy-MM-dd HH:mm:ss")); } if (q.endtime > DateTime.MinValue) { sql.AppendFormat(" and ia.create_dtim<='{0}' ", q.endtime.ToString("yyyy-MM-dd HH:mm:ss")); } if (!string.IsNullOrEmpty(q.doc_no))//by zhaozhi0623j add 20151006 用於庫存調整單號查詢 { sql.AppendFormat(" and ia.doc_no='{0}' ", q.doc_no); } if (q.doc_userid != 0)//by zhaozhi0623j add 20151006 用於庫存調整管理員查詢 { sql.AppendFormat(" and ia.create_user='******' ", q.doc_userid); } sql.AppendFormat(" order by ia.row_id ;"); return _access.getDataTableForObj<IialgQuery>(sql.ToString()); } catch (Exception ex) { throw new Exception("IialgDao-->GetExportIialgList-->" + ex.Message + sql.ToString(), ex); } }
public int SaveIinvd(IinvdQuery query) { query.Replace4MySQL(); int falg = 0; StringBuilder sql = new StringBuilder(); try { if (query.pwy_dte_ctl == "Y") { if (query.row_id != 0) { if (query.prod_qty == 0) { sql.AppendFormat("DELETE FROM iinvd WHERE row_id={0};", query.row_id); } else { sql.AppendFormat("UPDATE iinvd SET prod_qty={0},change_user={2},change_dtim='{3}' WHERE row_id={1};", query.prod_qty, query.row_id, query.change_user, CommonFunction.DateTimeToString(query.change_dtim)); } } else { sql.AppendFormat("UPDATE iinvd SET prod_qty=prod_qty+{0},change_user={2},change_dtim='{3}' WHERE plas_loc_id='{1}';", query.prod_qty, query.plas_loc_id, query.change_user, CommonFunction.DateTimeToString(query.change_dtim)); } _access.execCommand(sql.ToString()); falg = 1; } else { if (query.row_id != 0) { sql.Append("update iinvd set prod_qty=" + query.prod_qty + ",change_user="******",change_dtim='" + CommonFunction.DateTimeToString(query.change_dtim) + "' where row_id =" + query.row_id); return _access.execCommand(sql.ToString()); } else { sql.AppendFormat("SELECT row_id,prod_qty,made_date,cde_dt FROM iinvd WHERE plas_loc_id='{0}' AND ista_id='A' ORDER BY made_date;", query.plas_loc_id); DataTable table = _access.getDataTable(sql.ToString()); string row_id = ""; string row_idend = ""; int row_id_end_prod_pty = 0; query.prod_qtys = GetProd_qty((int)query.item_id, query.plas_loc_id, "", ""); int prod_qty = query.prod_qtys - query.prod_qty; int sc_num_chg=0; int i = 0; IialgQuery iialg = new IialgQuery(); IialgMgr _iialgMgr; DateTime date = DateTime.Now; int temp = 0; iialg.loc_id = query.plas_loc_id; iialg.item_id = query.item_id; iialg.iarc_id = "循環盤點"; iialg.create_user = query.create_user; iialg.type = 2; for (i = 0; i < table.Rows.Count; i++) { if ((int)table.Rows[i][1] <= prod_qty || (int)table.Rows[i][1] == 0) { row_id += table.Rows[i][0] + ","; prod_qty = prod_qty - (int)table.Rows[i][1]; sc_num_chg+=(int)table.Rows[i][1]; DateTime.TryParse(table.Rows[i][3].ToString(), out date); iialg.cde_dt = date; int.TryParse(table.Rows[i][1].ToString(), out temp); iialg.qty_o = temp;//原始庫存數量 iialg.adj_qty = -temp; iialg.create_dtim = DateTime.Now; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); if(DateTime.TryParse(table.Rows[i][3].ToString(), out date)) { iialg.made_dt = date; } _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); } else { row_idend = table.Rows[i][0].ToString(); row_id_end_prod_pty = prod_qty; break; } } if (row_id != "") { _access.execCommand("DELETE FROM iinvd WHERE row_id IN(" + row_id.TrimEnd(',') + ")"); falg = 1; } if (i != table.Rows.Count) { DateTime.TryParse(table.Rows[i][3].ToString(), out date); iialg.cde_dt = date; int.TryParse(table.Rows[i][1].ToString(), out temp); iialg.qty_o = temp;//原始庫存數量 sc_num_chg += row_id_end_prod_pty; iialg.adj_qty = -row_id_end_prod_pty; iialg.create_dtim = DateTime.Now; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); if (DateTime.TryParse(table.Rows[i][3].ToString(), out date)) { iialg.made_dt = date; } _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); falg= _access.execCommand("update iinvd set prod_qty=prod_qty-" + row_id_end_prod_pty + ",change_user="******",change_dtim='" + CommonFunction.DateTimeToString(query.change_dtim) + "' where row_id =" + row_idend); } IstockChangeQuery istock = new IstockChangeQuery(); istock.sc_trans_id = iialg.doc_no; istock.item_id = query.item_id; istock.sc_istock_why = 2; istock.sc_trans_type = 2; istock.sc_num_old = query.prod_qtys;//原始庫存數量 istock.sc_num_chg = -sc_num_chg;//轉移數量 istock.sc_num_new = GetProd_qty((int)query.item_id, query.plas_loc_id, "", "");//結餘數量 istock.sc_time = DateTime.Now; istock.sc_user = query.create_user; istock.sc_note = "循環盤點"; IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString); istockMgr.insert(istock); } } } catch (Exception ex) { throw new Exception("IinvdDao-->SaveIinvd-->" + ex.Message + sql.ToString(), ex); } return falg; }
public JsonResult IinvdSave() { bool falg = false; string message ="保存失敗"; try { string row_id = ""; int prod_qty = 0; if (Request.Params["rowid"].Length > 5) { row_id = Request.Params["rowid"].Substring(5); } string changeStore = Request.Params["changeStore"]; int temp1=0; if (int.TryParse(changeStore, out temp1)) { if (temp1 < 0) { falg = false; message = "庫存不能小於1"; } else { _iinvd = new IinvdMgr(mySqlConnectionString); IinvdQuery iinvd = new IinvdQuery(); iinvd.pwy_dte_ctl = Request.Params["pwy_dte_ctl"]; if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } int id = 0; if (int.TryParse(row_id, out id)) { iinvd.row_id = id; } if (int.TryParse(changeStore, out id)) { iinvd.prod_qty = id; } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out id)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } iinvd.create_user = (Session["caller"] as Caller).user_id; iinvd.create_dtim = DateTime.Now; iinvd.change_user = iinvd.create_user; iinvd.change_dtim = iinvd.create_dtim; iinvd.prod_qtys = _iinvd.GetProd_qty(Convert.ToInt32(iinvd.item_id), iinvd.plas_loc_id, "", iinvd.row_id.ToString()); if (iinvd.pwy_dte_ctl == "Y") { List<DateTime> list = new List<DateTime>(); list=_iinvd.GetCde_dt(iinvd.row_id); if(list.Count>0) { iinvd.cde_dt = list[0]; iinvd.made_date = list[1]; } } else { iinvd.made_date = iinvd.create_dtim; iinvd.cde_dt = iinvd.create_dtim; } if (iinvd.row_id != 0) { if (iinvd.pwy_dte_ctl == "Y") { prod_qty = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id, iinvd.pwy_dte_ctl, iinvd.row_id.ToString()); if (prod_qty == iinvd.prod_qty) { falg = true; return Json(new { success = falg, message = message }); } else if (_iinvd.SaveIinvd(iinvd) == 1) { falg = true; } } if (iinvd.pwy_dte_ctl == "N" || iinvd.pwy_dte_ctl == "") { iinvd.row_id = 0; if (iinvd.prod_qtys < iinvd.prod_qty) { iinvd.ista_id = "A"; iinvd.prod_qty = iinvd.prod_qty - iinvd.prod_qtys; iinvd.cde_dt = DateTime.Now; int result=_iinvd.GetIinvdCount(iinvd); if (result>1) { prod_qty = result - 1; falg = true; } else { if (_iinvd.Insert(iinvd) == 1) { falg = true; } } } else if (iinvd.prod_qtys> iinvd.prod_qty) { if (_iinvd.SaveIinvd(iinvd) == 1) { falg = true; return Json(new { success = falg, message = message }); } } else if (iinvd.prod_qtys == iinvd.prod_qty) { falg = true; return Json(new { success = falg, message = message }); } } IialgQuery iialg = new IialgQuery(); iialg.cde_dt = iinvd.cde_dt; iialg.qty_o = prod_qty;//原始庫存數量 iialg.loc_id = iinvd.plas_loc_id; iialg.item_id = iinvd.item_id; iialg.iarc_id = "循環盤點"; if (iinvd.pwy_dte_ctl == "Y") { iialg.adj_qty = iinvd.prod_qty - prod_qty; } else { iialg.adj_qty = iinvd.prod_qty-prod_qty;//轉移數量 } iialg.create_dtim = DateTime.Now; iialg.create_user = iinvd.create_user; iialg.type = 2; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); iialg.made_dt = iinvd.made_date; iialg.cde_dt = iinvd.cde_dt; _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); IstockChangeQuery istock = new IstockChangeQuery(); istock.sc_trans_id = iialg.doc_no; istock.item_id = iinvd.item_id; istock.sc_istock_why = 2; istock.sc_trans_type = 2; istock.sc_num_old = iinvd.prod_qtys;//原始庫存數量 istock.sc_num_chg = iialg.adj_qty;//轉移數量 istock.sc_num_new = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id,"","");//結餘數量 istock.sc_time = iinvd.create_dtim; istock.sc_user = iinvd.create_user; istock.sc_note = "循環盤點"; IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString); istockMgr.insert(istock); } else { return Json(new { success = falg }); } } } else { message = "庫存不能小於1"; } } 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); } return Json(new { success = falg,message=message }); }
//RF直接庫調 public HttpResponseBase RFKT() { string json = string.Empty; IialgQuery q = new IialgQuery(); uint id = 0; DateTime dt = new DateTime(); int sun = 0; try { if (uint.TryParse(Request.Params["item_id"].ToString(), out id)) {//商品id q.item_id = id; } if (DateTime.TryParse(Request.Params["made_date"].ToString(), out dt)) {//商品製造日期 q.made_dt = dt; } if (int.TryParse(Request.Params["prod_qty"].ToString(), out sun)) {//商品原有數量 q.qty_o = sun; } if (int.TryParse(Request.Params["pnum"].ToString(), out sun)) {//商品撿貨數量 q.pnum = sun; } if (!string.IsNullOrEmpty(Request.Params["loc_id"].ToString())) {//商品撿貨數量 q.loc_id = Request.Params["loc_id"]; } if (!string.IsNullOrEmpty(Request.Params["order_id"])) { q.order_id = Request.Params["order_id"]; } q.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; //進行庫調 _iagMgr = new IialgMgr(mySqlConnectionString); if (q.loc_id == "YY999999") { json = "{success:false}"; } else { int result = _iagMgr.addIialgIstock(q); if (result == 2) { json = "{success:true,msg:2}"; } if (result == 100) { json = "{success:true,msg:100}"; } } } 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; }
// 庫調匯出 public void IialgExcel() { string json = string.Empty; IialgQuery q = new IialgQuery(); try { uint id; if (uint.TryParse(Request.Params["item_id"], out id))//獲取參數 { q.item_id = id; } if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { q.loc_id = Request.Params["loc_id"].ToString().ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["po_id"])) { q.po_id = Request.Params["po_id"].ToString(); } //if (!string.IsNullOrEmpty(Request.Params["iarc_id"])) //{ // q.iarc_id = Request.Params["iarc_id"].ToString(); //} if (Request.Params["doc_userid"].ToString() != "-1")//by zhaozhi0623j add 20151006 { q.doc_userid = int.Parse(Request.Params["doc_userid"]); } if (!string.IsNullOrEmpty(Request.Params["doc_no"].Trim().ToUpper()))//by zhaozhi0623j add 20151006 { q.doc_no = Request.Params["doc_no"].Trim().ToUpper(); } DateTime time = DateTime.MinValue; if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time)) { q.starttime = time; } if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time)) { q.endtime = time; } if (!System.IO.Directory.Exists(Server.MapPath(excelPath))) { System.IO.Directory.CreateDirectory(Server.MapPath(excelPath)); } DataTable dtHZ = new DataTable(); string newExcelName = string.Empty; #region 表頭 dtHZ.Columns.Add("編號", typeof(String)); dtHZ.Columns.Add("庫存調整單號", typeof(String)); dtHZ.Columns.Add("主料位", typeof(String)); dtHZ.Columns.Add("調整料位", typeof(String)); dtHZ.Columns.Add("商品細項編號", typeof(String)); dtHZ.Columns.Add("商品名稱", typeof(String)); dtHZ.Columns.Add("商品規格", typeof(String)); dtHZ.Columns.Add("製造日期", typeof(String)); dtHZ.Columns.Add("有效日期", typeof(String)); dtHZ.Columns.Add("新製造日期", typeof(String)); dtHZ.Columns.Add("新有效日期", typeof(String)); dtHZ.Columns.Add("調整前數量", typeof(String)); dtHZ.Columns.Add("調整數量", typeof(String)); dtHZ.Columns.Add("調整后數量", typeof(String)); dtHZ.Columns.Add("調整原因", typeof(String)); dtHZ.Columns.Add("調整日期", typeof(String)); dtHZ.Columns.Add("調整人員", typeof(String)); dtHZ.Columns.Add("前置單號", typeof(String)); dtHZ.Columns.Add("備註欄", typeof(String)); #endregion List<IialgQuery> store = new List<IialgQuery>(); _iagMgr = new IialgMgr(mySqlConnectionString); q.IsPage = false; store = _iagMgr.GetExportIialgList(q); int i = 1; foreach (var item in store) { DataRow dr = dtHZ.NewRow(); dr[0] = i++; dr[1] = item.doc_no; dr[2] = item.loc_id; dr[3] = item.loc_R; dr[4] = item.item_id; dr[5] = item.product_name; dr[6] = item.prod_sz; dr[7] = item.made_dt; dr[8] = item.cde_dt; if (item.c_made_dt > DateTime.MinValue) { dr[9] = item.c_made_dt; } else { dr[9] = ""; } if (item.c_cde_dt > DateTime.MinValue) { dr[10] = item.c_cde_dt; } else { dr[10] = ""; } dr[11] = item.qty_o; dr[12] = item.adj_qty; dr[13] = item.qty_o + item.adj_qty; dr[14] = item.iarc_id; dr[15] = item.create_dtim; dr[16] = item.name; dr[17] = item.po_id; dr[18] = item.remarks; dtHZ.Rows.Add(dr); } if (System.IO.File.Exists(newExcelName)) { System.IO.File.Delete(newExcelName); } string fileName = "庫存調整歷史記錄_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; string fileNametwo = "庫存調整歷史記錄_" + DateTime.Now.ToString("yyyyMMddHHmm"); MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, fileNametwo); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.BinaryWrite(ms.ToArray()); } 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,data:[]}"; } }
//庫調記錄列表 public HttpResponseBase GetIialgList() { string json = string.Empty; IialgQuery q = new IialgQuery(); q.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 q.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 uint id; int rid = 0; if (uint.TryParse(Request.Params["item_id"].ToUpper(), out id))//獲取參數 { q.item_id = id; } if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { q.loc_id = Request.Params["loc_id"].ToString().ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["po_id"])) { q.po_id = Request.Params["po_id"].ToString(); } if (Request.Params["doc_userid"].ToString() != "-1") { q.doc_userid = int.Parse(Request.Params["doc_userid"]); } //if (!string.IsNullOrEmpty(Request.Params["iarc_id"])) //{ // q.iarc_id = Request.Params["iarc_id"].ToString(); //} DateTime time = DateTime.MinValue; if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time)) { q.starttime = time; } if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time)) { q.endtime = time; } if (!string.IsNullOrEmpty(Request.Params["doc_no"].Trim().ToUpper()))//by zhaozhi0623j add 20151006 { q.doc_no = Request.Params["doc_no"].Trim().ToUpper(); } try { List<IialgQuery> store = new List<IialgQuery>(); _iagMgr = new IialgMgr(mySqlConnectionString); int totalCount = 0; store = _iagMgr.GetIialgList(q, out totalCount); foreach (var item in store) { item.id = rid++; item.qty = item.qty_o + item.adj_qty; } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, 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,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase InsertIialg() { string json = string.Empty; IialgQuery iagQuery = new IialgQuery(); Iinvd invd = new Iinvd(); int result = 0; try { invd.row_id = Convert.ToInt32(Request.Params["row_id"]);//行號碼 _iinvd = new IinvdMgr(mySqlConnectionString); DataTable dt = _iinvd.GetRowMsg(invd);//首先根據row_id 獲取到製造日期和有效日期 iagQuery.made_dt = Convert.ToDateTime(dt.Rows[0]["made_date"]);//製造日期 iagQuery.cde_dt = Convert.ToDateTime(dt.Rows[0]["cde_dt"]);//有效日期 if (!string.IsNullOrEmpty(Request.Params["item_id"]))//商品細項編號 { iagQuery.item_id = Convert.ToUInt32(Request.Params["item_id"]); } if (!string.IsNullOrEmpty(Request.Params["po_id"])) { iagQuery.po_id = Request.Params["po_id"];//採購單編號 } if (!string.IsNullOrEmpty(Request.Params["iarc_id"])) { iagQuery.iarc_id = Request.Params["iarc_id"];//庫調原因 } if (!string.IsNullOrEmpty(Request.Params["ktloc_id"])) { iagQuery.loc_id = Request.Params["ktloc_id"].ToUpper();//料位編號 } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { iagQuery.doc_no = Request.Params["doc_no"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["remarks"])) { iagQuery.remarks = Request.Params["remarks"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["made_date"]))//創建時間 { iagQuery.made_dt = Convert.ToDateTime(Request.Params["made_date"]); } if (!string.IsNullOrEmpty(Request.Params["end_date"]))//有效日期 { iagQuery.cde_dt = Convert.ToDateTime(Request.Params["end_date"]);//庫調單號 } int kucuncount = Convert.ToInt32(Request.Params["benginnumber"]);//庫存數量 int tiaozhengcount = Convert.ToInt32(Request.Params["changenumber"]);//調整數量 int kucuntype = Convert.ToInt32(Request.Params["kutiaotype"]);//庫存類型 if (kucuntype == 1) { iagQuery.adj_qty = tiaozhengcount; //調整庫存 } else { iagQuery.adj_qty = tiaozhengcount * (-1);//調整庫存 } iagQuery.qty_o = kucuncount;//原來庫存 iagQuery.create_dtim = DateTime.Now; iagQuery.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Params["ktloc_id"])) { iagQuery.loc_id = Request.Params["ktloc_id"]; } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { iagQuery.doc_no = Request.Params["doc_no"]; } _iagMgr = new IialgMgr(mySqlConnectionString); result = _iagMgr.insertiialg(iagQuery); if (result > 0) { json = "{success:true}";//返回json數據 } else { json = "{success:false}";//返回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,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public void KTPrintPDF() { PdfHelper pdf = new PdfHelper(); List<string> pdfList = new List<string>(); float[] arrColWidth = new float[] { 60, 60, 100, 60, 50, 30, 60, 60, 60, 60 }; int index = 0; string newFileName = string.Empty; string newName = string.Empty; string json = string.Empty; IialgQuery q = new IialgQuery(); if (!string.IsNullOrEmpty(Request.Params["KT_NO"].Trim().ToUpper()))//by zhaozhi0623j add 20151006 { q.doc_no = Request.Params["KT_NO"].Trim().ToUpper(); } try { List<IialgQuery> store = new List<IialgQuery>(); _iagMgr = new IialgMgr(mySqlConnectionString); int totalCount = 0; q.IsPage = false; store = _iagMgr.GetIialgList(q, out totalCount); int rid = 0; DataTable _dtBody = new DataTable(); if (store.Count > 0) { _dtBody.Columns.Add("商品細項編號", typeof(string)); _dtBody.Columns.Add("主料位", typeof(string)); _dtBody.Columns.Add("商品名稱", typeof(string)); _dtBody.Columns.Add("規格", typeof(string)); _dtBody.Columns.Add("調整原因", typeof(string)); _dtBody.Columns.Add("數量", typeof(string)); _dtBody.Columns.Add("调整料位", typeof(string)); _dtBody.Columns.Add("有效日期", typeof(string)); _dtBody.Columns.Add("前置單號", typeof(string)); _dtBody.Columns.Add("備註", typeof(string)); for (int i = 0; i < store.Count; i++) { store[i].id = rid++; store[i].qty = store[i].qty_o + store[i].adj_qty; DataRow newRow = _dtBody.NewRow(); newRow["商品細項編號"] = store[i].item_id; newRow["主料位"] = store[i].loc_id; newRow["商品名稱"] = store[i].product_name; newRow["規格"] = string.IsNullOrEmpty(store[i].prod_sz) ? " " : store[i].prod_sz; newRow["調整原因"] = string.IsNullOrEmpty(store[i].iarc_id) ? " " : store[i].iarc_id; newRow["數量"] = store[i].adj_qty; newRow["调整料位"] = store[i].loc_R; newRow["有效日期"] = store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10) == "0001-01-01" ? " " : store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10); newRow["前置單號"] = string.IsNullOrEmpty(store[i].po_id) ? " " : store[i].po_id; newRow["備註"] = string.IsNullOrEmpty(store[i].remarks) ? " " : store[i].remarks; _dtBody.Rows.Add(newRow); } } string UsingName = " "; String UsingTime = " "; if (store.Count > 0) { UsingName = store[0].name; UsingTime = store[0].create_dtim.ToString("yyyy/MM/dd"); } BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑 string filename = "庫存調整" + DateTime.Now.ToString("yyyyMMddHHmmss"); Document document = new Document(PageSize.A4.Rotate()); string newPDFName = Server.MapPath(excelPath) + filename; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create)); document.Open(); #region 庫存調整單頭 PdfPTable ptable = new PdfPTable(10); ptable.WidthPercentage = 100;//表格寬度 ptable.SetTotalWidth(arrColWidth); PdfPCell cell = new PdfPCell(); cell = new PdfPCell(new Phrase("執行人員:" + UsingName, new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 8; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("執行日期:" + UsingTime, new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 8; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 4))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 10; //cell.DisableBorderSide(1); cell.DisableBorderSide(2); //cell.DisableBorderSide(4); //cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" 庫存調整單", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); // cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); // cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("單號" + ":" + q.doc_no, new iTextSharp.text.Font(bf, 10)));// ipoStore[a].po_type_desc cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); // cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 4))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 10; cell.DisableBorderSide(1); //cell.DisableBorderSide(2); // cell.DisableBorderSide(4); //cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("商品細項編號", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("主料位", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("調整原因", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("數量", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); //cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("调整料位", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("前置單號", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); //cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 10))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //cell.DisableBorderSide(1); // cell.DisableBorderSide(2); //cell.DisableBorderSide(4); //cell.DisableBorderSide(8); ptable.AddCell(cell); //cell.UseAscender = true; //cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 //cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 //cell.BorderWidth = 0.1f; //cell.BorderColor = new BaseColor(0, 0, 0); #endregion #region 庫存調整單尾 PdfPTable ptablefoot = new PdfPTable(10); ptablefoot.WidthPercentage = 100;//表格寬度 ptablefoot.SetTotalWidth(arrColWidth); PdfPCell footcell = new PdfPCell(); footcell.UseAscender = true; footcell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 footcell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 footcell.BorderWidth = 0.1f; footcell.BorderColor = new BaseColor(0, 0, 0); footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 15))); footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 //footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右 footcell.Colspan = 10; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); footcell = new PdfPCell(new Phrase("印表日期:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), new iTextSharp.text.Font(bf, 10))); footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右 // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右 footcell.Colspan = 2; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 10))); footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右 // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右 footcell.Colspan = 1; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); footcell = new PdfPCell(new Phrase("印表人:" + (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, new iTextSharp.text.Font(bf, 10))); footcell.VerticalAlignment = Element.ALIGN_RIGHT;//水平居右 footcell.Colspan = 2; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 10))); footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右 // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右 footcell.Colspan = 3; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); footcell = new PdfPCell(new Phrase("主管簽核:__________________", new iTextSharp.text.Font(bf, 10))); footcell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 footcell.Colspan = 2; footcell.DisableBorderSide(1); footcell.DisableBorderSide(2); footcell.DisableBorderSide(4); footcell.DisableBorderSide(8); ptablefoot.AddCell(footcell); #endregion if (store.Count == 0) { document = new Document(PageSize.A4.Rotate()); if (!document.IsOpen()) { document.Open(); } cell = new PdfPCell(new Phrase(" ", font)); cell.Colspan = 4; cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("此庫調單庫調數據不存在!", font)); cell.Colspan = 7; cell.DisableBorderSide(4); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 ptable.AddCell(cell); // document.Add(ptable); //document.Add(ptablefoot); newFileName = newPDFName + "_part" + index++ + "." + "pdf"; pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(store.Count.ToString()));/*第一7是列,第二個是行*/ pdfList.Add(newFileName); } else { newFileName = newPDFName + "_part" + index++ + "." + "pdf"; pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(store.Count.ToString()));/*第一7是列,第二個是行*/ pdfList.Add(newFileName); } //newFileName = newPDFName + "_part" + index++ + "." + "pdf"; //pdf.ExportDataTableToPDF(newFileName, ptable, "", ""); //pdfList.Add(newFileName); //document.Add(ptable); //document.NewPage(); newFileName = newPDFName + "." + "pdf"; pdf.MergePDF(pdfList, newFileName); Response.Clear(); Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf"); Response.WriteFile(newFileName); } catch (Exception) { throw; } }
// 更新表Iinvd庫存鎖的狀態 public JsonResult UpdateIinvdActive() { string jsonStr = string.Empty; try { _iinvd = new IinvdMgr(mySqlConnectionString); Iinvd nvd = new Iinvd(); IialgQuery q = new IialgQuery(); _iagMgr = new IialgMgr(mySqlConnectionString); int id = Convert.ToInt32(Request.Params["id"]); string active = Request.Params["active"]; string lock_id = Request.Params["lock_id"]; if (!string.IsNullOrEmpty(Request.Params["po_id"].ToString())) { q.po_id = Request.Params["po_id"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["remarks"].ToString())) { q.remarks = Request.Params["remarks"].ToString(); } if (active == "H") { nvd.ista_id = "A"; nvd.qity_id = 0; } else if (active == "A") { nvd.qity_id = Convert.ToInt32(lock_id); nvd.ista_id = "H"; } nvd.row_id = id; nvd.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); nvd.change_dtim = DateTime.Now; if (_iinvd.UpdateIinvdLock(nvd, q) > 0) { //加鎖成功往iialg插入一條數據;解鎖不需要記錄 if (active == "A") { Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault(); q.loc_id = store.plas_loc_id; q.item_id = store.item_id; q.iarc_id = "KS"; q.qty_o = store.prod_qty; q.type = 1; q.adj_qty = -store.prod_qty; q.create_dtim = DateTime.Now; q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); q.made_dt = store.made_date; q.cde_dt = store.cde_dt; if (_iagMgr.insertiialg(q) > 0) { Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); ProductItem proitem = new ProductItem(); _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = store.prod_qty; proitem.Item_Stock = -item_stock; proitem.Item_Id = store.item_id; string path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } else { Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault(); q.loc_id = store.plas_loc_id; q.item_id = store.item_id; q.iarc_id = "KS"; q.qty_o = 0; q.type = 1; q.adj_qty = store.prod_qty; q.create_dtim = DateTime.Now; q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); q.made_dt = store.made_date; q.cde_dt = store.cde_dt; if (_iagMgr.insertiialg(q) > 0) { Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); ProductItem proitem = new ProductItem(); _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = store.prod_qty; proitem.Item_Stock = item_stock; proitem.Item_Id = store.item_id; string path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } } else { return Json(new { success = "false" }); } } 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); return Json(new { success = "false" }); } }
public HttpResponseBase InsertIinvd() { string jsonStr = String.Empty; Int64 aaa = 0; //無用變數 uint p = 0; //無用變數 try { Iinvd m = new Iinvd(); IialgQuery ia = new IialgQuery(); Iupc iu = new Iupc(); ProductItem proitem = new ProductItem(); Caller call = new Caller(); IstockChangeQuery stock = new IstockChangeQuery(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); string path = ""; _iinvd = new IinvdMgr(mySqlConnectionString); _iagMgr = new IialgMgr(mySqlConnectionString); _IiupcMgr = new IupcMgr(mySqlConnectionString); #region 獲取數據往 if (Int64.TryParse(Request.Params["item_id"].ToString(), out aaa)) { if (uint.TryParse(Request.Params["item_id"].ToString(), out p)) { m.item_id = uint.Parse(Request.Params["item_id"].ToString()); } if (Request.Params["item_id"].ToString().Length > 6) { m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString()); } } else { if (Request.Params["item_id"].ToString().Length > 6) { m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString()); } } m.dc_id = 1; m.whse_id = 1; m.prod_qty = Int32.Parse(Request.Params["prod_qty"].ToString());//數量 DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); DateTime dtime; if (DateTime.TryParse(Request.Params["startTime"].ToString(), out dtime)) {//用戶填寫創建時間算出有效日期 DateTime start = DateTime.Parse(Request.Params["startTime"].ToString()); m.made_date = start; if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p)) { m.cde_dt = start.AddDays(Int32.Parse(Request.Params["cde_dt_incr"].ToString())); } else { m.cde_dt = DateTime.Now; } } else { if (DateTime.TryParse(Request.Params["cde_dt"].ToString(), out dtime)) {//用戶填寫有效日期算出製造日期 m.cde_dt = DateTime.Parse(Request.Params["cde_dt"].ToString());//有效時間 if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p)) { m.made_date = m.cde_dt.AddDays(-Int32.Parse(Request.Params["cde_dt_incr"].ToString())); } else { m.made_date = today; } } else { m.cde_dt = today; m.made_date = today; } } m.cde_dt = DateTime.Parse(m.cde_dt.ToShortDateString()); m.made_date = DateTime.Parse(m.made_date.ToShortDateString()); m.plas_loc_id = Request.Params["plas_loc_id"].ToString().ToUpper();//上架料位 string loc_id = Request.Params["loc_id"].ToString().ToUpper(); m.change_dtim = DateTime.Now;//編輯時間 m.receipt_dtim = DateTime.Now;//收貨時間 m.create_user = (Session["caller"] as Caller).user_id; #endregion #region 獲取數據添加打iialg ia.loc_id = m.plas_loc_id.ToString().ToUpper(); ia.item_id = m.item_id; stock.sc_trans_type = 0; if (!string.IsNullOrEmpty(Request.Params["iarc_id"].ToString())) { ia.iarc_id = Request.Params["iarc_id"].ToString(); } else { ia.iarc_id = "PC"; stock.sc_trans_type = 1;//收貨上架 } //if (ia.iarc_id == "DR" || ia.iarc_id == "KR") //{ // type = 2;//RF理貨 //} ia.create_dtim = DateTime.Now; ia.create_user = m.create_user; ia.doc_no = "P" + DateTime.Now.ToString("yyyyMMddHHmmss"); if (!string.IsNullOrEmpty(Request.Params["doc_num"])) { ia.doc_no = Request.Params["doc_num"]; stock.sc_trans_id = ia.doc_no;//交易單號 } if (!string.IsNullOrEmpty(Request.Params["Po_num"])) { ia.po_id = Request.Params["Po_num"]; stock.sc_cd_id = ia.po_id;//前置單號 } if (!string.IsNullOrEmpty(Request.Params["remark"])) { ia.remarks = Request.Params["remark"]; stock.sc_note = ia.remarks;//備註 } ia.made_dt = m.made_date; ia.cde_dt = m.cde_dt; #endregion #region 獲取店內條碼-=添加條碼 if (!string.IsNullOrEmpty(Request.Params["vendor_id"].ToString())) { iu.upc_id = CommonFunction.GetUpc(m.item_id.ToString(), Request.Params["vendor_id"].ToString(), m.cde_dt.ToString("yyMMdd")); } iu.item_id = m.item_id; iu.upc_type_flg = "2";//店內碼 iu.create_user = m.create_user; string result = _IiupcMgr.IsExist(iu);//是否有重複的條碼 if (result == "0") { if (_IiupcMgr.Insert(iu) < 1) { jsonStr = "{success:true,msg:2}"; } } #endregion #region 新增/編輯 #region 庫存調整的時候,商品庫存也要調整 _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = m.prod_qty; proitem.Item_Stock = item_stock; proitem.Item_Id = m.item_id; #endregion if (_iinvd.IsUpd(m, stock) > 0) {//編輯 ia.qty_o = _iinvd.Selnum(m); ia.adj_qty = m.prod_qty; m.prod_qty = ia.qty_o + m.prod_qty; if (m.prod_qty >= 0) { if (_iinvd.Upd(m) > 0) { if (Request.Params["iialg"].ToString() == "Y") {// if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//更新成功 } } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:false,msg:1}";//庫存為負數 } } else {//新增 m.ista_id = "A"; m.create_dtim = DateTime.Now; //創建時間 if (_iinvd.Insert(m) > 0) { _IlocMgr = new IlocMgr(mySqlConnectionString); Iloc loc = new BLL.gigade.Model.Iloc(); loc.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); loc.change_dtim = DateTime.Now; loc.loc_id = m.plas_loc_id.ToString().ToUpper(); if (loc_id.Trim() != m.plas_loc_id.Trim())//判斷如果是主料位不需要進行多餘的操作 { if (_IlocMgr.SetIlocUsed(loc) > 0) { if (Request.Params["iialg"].ToString() == "Y") { if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } ia.qty_o = 0; ia.adj_qty = m.prod_qty; if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//新增成功 } } else { jsonStr = "{success:false,msg:1}";//新增失敗 } } else { if (Request.Params["iialg"].ToString() == "Y") { if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } ia.qty_o = 0; ia.adj_qty = m.prod_qty; if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//新增成功 } } } else { jsonStr = "{success:false,msg:1}"; } } #endregion } 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; }
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; }
public HttpResponseBase SaveIinvd() { string json = "{success:false,message:'系統異常'}"; try { int temp = 0; if (int.TryParse(Request.Params["prod_qty"], out temp)) { if (temp > 0) { IinvdQuery iinvd = new IinvdQuery(); if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out temp)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } #region 判斷是否指定主料位 IlocQuery ilocquery = new IlocQuery(); _IiplasMgr = new IplasMgr(mySqlConnectionString); IplasQuery iplasquery = new IplasQuery(); iplasquery.item_id = iinvd.item_id; IIlocImplMgr ilocMgr = new IlocMgr(mySqlConnectionString); IplasDao iplasdao = new IplasDao(mySqlConnectionString); int total = 0; ilocquery.loc_id = iinvd.plas_loc_id; ilocquery.lcat_id = "0"; ilocquery.lsta_id = ""; ilocquery.IsPage = false; List<IlocQuery> listiloc = ilocMgr.GetIocList(ilocquery, out total); if (listiloc.Count > 0) { string lcat_id = listiloc.Count == 0 ? "" : listiloc[0].lcat_id; if (lcat_id == "S") { string item_id = iplasdao.Getlocid(ilocquery.loc_id); if (item_id == "") { Iplas iplas = new Iplas(); if (int.TryParse(Request.Params["item_id"], out temp)) { iplas.item_id = uint.Parse(Request.Params["item_id"]); if (_IiplasMgr.IsTrue(iplas) == "false") { json = "{success:false,message:'不存在該商品編號'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } if (_IiplasMgr.GetIplasid(iplasquery) > 0) { json = "{success:false,message:'此商品主料位非該料位'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } Iloc iloc = new Iloc(); iloc.loc_id = iinvd.plas_loc_id; if (_IiplasMgr.GetLocCount(iloc) <= 0) { json = "{success:false,message:'該料位已鎖定或被指派'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } iplas.loc_id = iloc.loc_id; iplas.loc_stor_cse_cap = 100; iplas.create_user = (Session["caller"] as Caller).user_id; iplas.create_dtim = DateTime.Now; iplas.change_user = (Session["caller"] as Caller).user_id; iplas.change_dtim = DateTime.Now; _IiplasMgr.InsertIplas(iplas); } } } } #endregion iinvd.create_user = (Session["caller"] as Caller).user_id; iinvd.create_dtim = DateTime.Now; iinvd.change_user = iinvd.create_user; iinvd.change_dtim = iinvd.create_dtim; iinvd.ista_id = "A"; if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } int change_prod_qty = int.Parse(Request.Params["prod_qty"]); iinvd.prod_qty = change_prod_qty; if (!string.IsNullOrEmpty(Request.Params["st_qty"])) { if (int.TryParse(Request.Params["st_qty"], out temp)) { iinvd.st_qty = int.Parse(Request.Params["st_qty"]); } } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out temp)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } DateTime date = DateTime.Now; if (DateTime.TryParse(Request.Params["datetimepicker1"], out date)) { iinvd.made_date = date; } else { iinvd.made_date = DateTime.Now; } _iinvd = new IinvdMgr(mySqlConnectionString); if (Request.Params["pwy_dte_ctl"] == "Y") { iinvd.pwy_dte_ctl = "Y"; IProductExtImplMgr productExt = new ProductExtMgr(mySqlConnectionString); int Cde_dt_incr = productExt.GetCde_dt_incr((int)iinvd.item_id); iinvd.cde_dt = date.AddDays(Cde_dt_incr); } else { iinvd.cde_dt = DateTime.Now; } iinvd.prod_qtys = _iinvd.GetProd_qty(Convert.ToInt32(iinvd.item_id), iinvd.plas_loc_id, "", iinvd.row_id.ToString()); IialgQuery iialg = new IialgQuery(); iialg.cde_dt = iinvd.cde_dt; int prod_qty = 0;// _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id, "", ""); int row = _iinvd.GetIinvdCount(iinvd); if (row > 1) { prod_qty = row - 1; json = "{success:true}"; } else { if (_iinvd.Insert(iinvd) == 1) { json = "{success:true}"; } } iialg.qty_o = prod_qty; iialg.loc_id = iinvd.plas_loc_id; iialg.item_id = iinvd.item_id; iialg.iarc_id = "循環盤點"; iialg.adj_qty = change_prod_qty; iialg.create_dtim = DateTime.Now; iialg.create_user = iinvd.create_user; iialg.type = 2; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); iialg.made_dt = iinvd.made_date; iialg.cde_dt = iinvd.cde_dt; _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); IstockChangeQuery istock = new IstockChangeQuery(); istock.sc_trans_id = iialg.doc_no; istock.item_id = iinvd.item_id; istock.sc_istock_why = 2; istock.sc_trans_type = 2; istock.sc_num_old = iinvd.prod_qtys; istock.sc_num_chg = iialg.adj_qty; istock.sc_num_new = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id,"N",""); istock.sc_time = iinvd.create_dtim; istock.sc_user = iinvd.create_user; istock.sc_note = "循環盤點"; IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString); istockMgr.insert(istock); } else { json = "{success:false,message:'庫存不能小於1'}"; } } else { json = "{success:false,message:'庫存請輸入數字'}"; } } 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; }