public DataTable GetCheckItemBak(ic_t_check_bak bak) { string sql = @"select i.*, isnull(b.stock_qty,0) stock_qty, isnull(b.cost_price,0) cost_price from bi_t_item_info i left join ic_t_check_bak b on b.item_no=i.item_no and b.branch_no='" + bak.branch_no + "' and b.sheet_no='" + bak.sheet_no + "' where 1=1 "; DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); var init = db.ExecuteToModel <ic_t_check_init>("select * from ic_t_check_init where sheet_no='" + bak.sheet_no + "'", null); if (init == null) { throw new Exception("批次单不存在"); } if (!string.IsNullOrEmpty(init.item_clsno)) { sql += " and i.item_clsno like '" + init.item_clsno + "%' "; } if (!string.IsNullOrEmpty(bak.item_no)) { sql += " and( i.item_no='" + bak.item_no + "' or i.item_subno='" + bak.item_no + "' or i.barcode='" + bak.item_no + "' )"; } DataTable tb = db.ExecuteToTable(sql, null); return(tb); }
public void GetCheckItemBak(WebHelper w, Dictionary <string, object> kv) { ic_t_check_bak bak = w.GetObject <ic_t_check_bak>("bak"); DataTable tb = bll.GetCheckItemBak(bak); w.Write(tb); }
public void AddChectInitSheet(global::Model.ic_t_check_init check_init, out string sheet_no) { sheet_no = ""; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); check_init.sheet_no = sheet_no = MaxCode(d, "PC"); check_init.create_time = DateTime.Now; check_init.update_time = DateTime.Now; d.Insert(check_init); //备份仓库 DataTable tb = d.ExecuteToTable(@"select * from ic_t_branch_stock s left join bi_t_item_info i on i.item_no=s.item_no where branch_no='" + check_init.branch_no + "'", null); foreach (DataRow dr in tb.Rows) { ic_t_check_bak bak = new ic_t_check_bak() { sheet_no = check_init.sheet_no, branch_no = check_init.branch_no, item_no = dr["item_no"].ToString(), stock_qty = Conv.ToDecimal(dr["stock_qty"]), cost_price = Conv.ToDecimal(dr["cost_price"]), price = Conv.ToDecimal(dr["last_price"]), sale_price = Conv.ToDecimal(dr["sale_price"]), create_time = DateTime.Now, update_time = DateTime.Now }; d.Insert(bak); } db.CommitTran(); } catch (Exception ex) { LogHelper.writeLog("CheckBLL.AddChectInitSheet()", ex.ToString(), check_init.sheet_no); db.RollBackTran(); throw ex; } finally { db.Close(); } }
DataTable ICheckBLL.GetCheckItemBak(ic_t_check_bak bak) { JsonRequest r = new JsonRequest(); r.Write <ic_t_check_bak>("bak", bak); r.request("/check?t=GetCheckItemBak"); if (!r.ReadSuccess()) { throw new Exception(r.ReadMessage()); } DataTable tb = r.GetDataTable(); return(tb); }
public DataTable GetCheckBak(ic_t_check_bak bak) { string sql = @"select b.* from ic_t_check_bak b left join bi_t_item_info i on i.item_no=b.item_no where 1=1 "; if (!string.IsNullOrEmpty(bak.sheet_no)) { sql += " and b.sheet_no='" + bak.sheet_no + "' "; } if (!string.IsNullOrEmpty(bak.item_no)) { sql += " and( i.item_no='" + bak.item_no + "' or i.item_subno='" + bak.item_no + "' or i.barcode='" + bak.item_no + "' )"; } DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); DataTable tb = db.ExecuteToTable(sql, null); return(tb); }
public void AddChectInitSheet(global::Model.ic_t_check_init check_init, out string sheet_no) { sheet_no = ""; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); string sql = $@"SELECT COUNT(1) FROM dbo.ic_t_check_init WHERE branch_no='{check_init.branch_no}' AND check_status='0'"; int count = d.ExecuteScalar(sql, null).ToInt32(); if (count > 0) { throw new Exception("该仓库存在未结束盘点单,不可创建新盘点单"); } check_init.sheet_no = sheet_no = MaxCode(d, "PC"); check_init.create_time = DateTime.Now; check_init.update_time = DateTime.Now; d.Insert(check_init); //备份仓库 DataTable tb = d.ExecuteToTable(@"select * from ic_t_branch_stock s left join bi_t_item_info i on i.item_no=s.item_no where branch_no='" + check_init.branch_no + "'", null); foreach (DataRow dr in tb.Rows) { ic_t_check_bak bak = new ic_t_check_bak() { sheet_no = check_init.sheet_no, branch_no = check_init.branch_no, item_no = dr["item_no"].ToString(), stock_qty = Conv.ToDecimal(dr["stock_qty"]), cost_price = Conv.ToDecimal(dr["cost_price"]), price = Conv.ToDecimal(dr["last_price"]), sale_price = Conv.ToDecimal(dr["sale_price"]), create_time = DateTime.Now, update_time = DateTime.Now }; d.Insert(bak); } db.CommitTran(); } catch (Exception ex) { Log.writeLog("CheckBLL.AddChectInitSheet()", ex.ToString(), check_init.sheet_no); db.RollBackTran(); throw ex; } finally { db.Close(); } }