public void GetCheckFinish(WebHelper w, Dictionary <string, object> kv) { ic_t_check_finish finish = w.GetObject <ic_t_check_finish>("finish"); DataTable tb = bll.GetCheckFinish(finish); w.Write(tb); }
private void tsbCheck_Click(object sender, EventArgs e) { try { if (!MyLove.PermissionsBalidation(this.Text, "05")) { return; } if (string.IsNullOrEmpty(this.txtSheet_no.Text)) { return; } IBLL.ICheckBLL bll = new BLL.CheckBLL(); Dictionary <string, object> dic = this.Tag as Dictionary <string, object>; if (!Conv.ControlsCom(this, dic)) { List <Model.ic_t_check_finish> lis = new List <Model.ic_t_check_finish>(); foreach (DataRow r in this.editGrid1.DataSource.Rows) { ic_t_check_finish item = new ic_t_check_finish() { sheet_no = this.txtSheet_no.Text, item_no = r["item_no"].ToString(), change_flag = r["change_flag"].ToString(), memo = r["memo"].ToString(), update_time = DateTime.Now }; lis.Add(item); } if (lis.Count > 0) { bll.UpdateCheckFinish(lis); } } bll.CheckPCSheet(new ic_t_check_init() { sheet_no = this.txtSheet_no.Text, memo = this.txtMemo.Text, approve_man = this.txtApproveMan.Text.Split('/')[0], end_date = DateTime.Now, }); IOrder order = this; order.ShowOrder(this.txtSheet_no.Text); MsgForm.ShowFrom("审核成功"); } catch (Exception ex) { MsgForm.ShowFrom(ex); } }
public DataTable GetCheckFinish(ic_t_check_finish finish) { string sql = @"select * from ic_t_check_finish f left join bi_t_item_info item on f.item_no=item.item_no left join bi_t_item_cls c on c.item_clsno=item.item_clsno where f.sheet_no='" + finish.sheet_no + "' "; DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); DataTable tb = db.ExecuteToTable(sql, null); return(tb); }
DataTable ICheckBLL.GetCheckFinish(ic_t_check_finish finish) { JsonRequest r = new JsonRequest(); r.Write <ic_t_check_finish>("finish", finish); r.request("/check?t=GetCheckFinish"); if (!r.ReadSuccess()) { throw new Exception(r.ReadMessage()); } DataTable tb = r.GetDataTable(); return(tb); }
public void UpdateCheckFinish(List <ic_t_check_finish> finishs) { var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // foreach (ic_t_check_finish f in finishs) { ic_t_check_finish item = d.ExecuteToModel <ic_t_check_finish>("select * from ic_t_check_finish where sheet_no='" + f.sheet_no + "' and item_no='" + f.item_no + "'", null); if (f.update_time <= item.update_time) { throw new Exception("库存已被修改"); } item.change_flag = item.change_flag; item.update_time = f.update_time; item.memo = f.memo; d.Update(item, "sheet_no,item_no", "change_flag,update_time,memo"); } // db.CommitTran(); } catch (Exception ex) { Log.writeLog("CheckBLL.CheckPDSheet()", ex.ToString()); db.RollBackTran(); throw ex; } finally { db.Close(); } }
void ICheckBLL.ChangeCheckSheet(Model.ic_t_check_master ord, List <Model.ic_t_check_detail> lines) { var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); // string sql = "select approve_flag,update_time from ic_t_check_master where sheet_no='" + ord.sheet_no + "'"; var tb = d.ExecuteToTable(sql, null); if (tb.Rows.Count == 0) { throw new Exception("单据不存在[" + ord.sheet_no + "]"); } else { var row = tb.Rows[0]; if (row["approve_flag"].ToString() == "1") { throw new Exception("单据已审核[" + ord.sheet_no + "]"); } if (Helper.Conv.ToDateTime(row["update_time"]) > ord.update_time) { throw new Exception("单据已被他人修改[" + ord.sheet_no + "]"); } } DataTable finfishtb = d.ExecuteToTable("select * from ic_t_check_detail where sheet_no='" + ord.sheet_no + "' ", null); sql = "delete from ic_t_check_detail where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); sql = "delete from ic_t_check_master where sheet_no='" + ord.sheet_no + "'"; d.ExecuteScalar(sql, null); // ord.update_time = DateTime.Now; d.Insert(ord); foreach (Model.ic_t_check_detail line in lines) { sql = "select isnull(max(flow_id),0) + 1 as flow_id from ic_t_check_detail "; line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); d.Insert(line); var finfish = d.ExecuteToModel <ic_t_check_finish>("select * from ic_t_check_finish where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "'", null); if (finfish == null) { finfish = new ic_t_check_finish() { sheet_no = ord.check_no, item_no = line.item_no, branch_no = ord.branch_no, change_flag = "1", sale_price = line.sale_price, stock_qty = line.stock_qty, create_time = DateTime.Now, in_price = line.in_price, memo = line.memo, real_qty = line.real_qty, update_time = DateTime.Now, }; d.Insert(finfish); } else { DataRow t = finfishtb.Select().Where(a => a["item_no"].ToString().Equals(finfish.item_no)).SingleOrDefault(); finfish.real_qty += line.real_qty; if (t != null) { finfish.real_qty -= Conv.ToDecimal(t["real_qty"]); } finfish.update_time = DateTime.Now; d.Update(finfish, "sheet_no,item_no"); } } // db.CommitTran(); } catch (Exception ex) { Log.writeLog("CheckBLL.ChangeCheckSheet()", ex.ToString(), ord.sheet_no); db.RollBackTran(); throw ex; } finally { db.Close(); } }
void ICheckBLL.AddCheckSheet(Model.ic_t_check_master ord, List <Model.ic_t_check_detail> lines, out string sheet_no) { sheet_no = ""; var db = new DB.DBByHandClose(Appsetting.conn); DB.IDB d = db; try { db.Open(); db.BeginTran(); sheet_no = MaxCode(d, "PD"); ord.sheet_no = sheet_no; ord.create_time = DateTime.Now; ord.update_time = ord.create_time; // d.Insert(ord); foreach (Model.ic_t_check_detail line in lines) { var bak = d.ExecuteToModel <ic_t_check_bak>("select * from ic_t_check_bak where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "' ", null); if (bak != null) { line.stock_qty = bak.stock_qty; line.in_price = bak.price; line.sale_price = bak.sale_price; line.balance_qty = line.real_qty - line.stock_qty; } string sql = "select isnull(max(flow_id),0) + 1 as flow_id from ic_t_check_detail "; line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null)); line.sheet_no = sheet_no; d.Insert(line); var finfish = d.ExecuteToModel <ic_t_check_finish>("select * from ic_t_check_finish where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "'", null); if (finfish == null) { finfish = new ic_t_check_finish() { sheet_no = ord.check_no, item_no = line.item_no, branch_no = ord.branch_no, change_flag = "1", sale_price = line.sale_price, stock_qty = line.stock_qty, create_time = DateTime.Now, in_price = line.in_price, memo = line.memo, real_qty = line.real_qty, update_time = DateTime.Now, }; d.Insert(finfish); } else { finfish.real_qty += line.real_qty; finfish.update_time = DateTime.Now; d.Update(finfish, "sheet_no,item_no"); } } // db.CommitTran(); } catch (Exception ex) { Log.writeLog("CheckBLL.AddCheckSheet()", ex.ToString(), ord.sheet_no); db.RollBackTran(); throw ex; } finally { db.Close(); } }