/// <summary> /// 更新状态 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static bool UpCode(Entity.GoodsCode gc) { if (DAL.GoodsDAL.UpCode(gc) > 0) { return(true); } else { return(false); } }
/// <summary> /// 未使用领取码 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static string CodesList(Entity.GoodsCode gc) { DataTable dt = EDAL.GoodsDAL.CodesList(gc); string codes = ""; for (int i = 0; i < dt.Rows.Count; i++) { codes += dt.Rows[i][0].ToString() + "\r\n"; } return(codes); }
/// <summary> /// 查找物品编码 /// </summary> /// <returns></returns> public static bool SearchCode(Entity.GoodsCode gc) { if (EDAL.GoodsDAL.SearchCode(gc) > 0) { return(true); } else { return(false); } }
/// <summary> /// 查询物品领取码 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static int SearchGC(Entity.GoodsCode gc) { try { return(EDAL.GoodsDAL.SearchGC(gc)); } catch { return(0000); } }
/// <summary> /// 判断是否使用 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static bool IfUse(Entity.GoodsCode gc) { string sql = "select GCState from GoodsCode Where GCID=" + gc.gcID + ""; if (DBHelper.GetScalar(sql).ToString() == "未领取") { return(true); } else { return(false); } }
/// <summary> /// 检测号码是否存在 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static bool SearchCode(Entity.GoodsCode gc) { string sql = "select COUNT(*) from GoodsCode where GCID=" + gc.gcID + ""; if ((int)DBHelper.GetScalar(sql) > 0) { return(true); } else { return(false); } }
private void btn_del_Click(object sender, EventArgs e) { string msg = ""; Entity.GoodsCode gc = new Entity.GoodsCode(); try { gc.gcID = int.Parse(this.txt_id.Text); } catch (Exception ex) { Msg.Box.Show(ex.Message); return; } if (BLL.GoodsBLL.UseCodes(gc, out msg) == true) { bool isGo = Msg.Box.RShow(msg, "发放确认", Msg.Box.Ico.Question); if (isGo == false) { return; } if (BLL.GoodsBLL.UpCode(gc) == true) { Msg.Box.Show("恭喜您,物品发放成功!"); this.txt_id.Clear(); } else { Msg.Box.Show("抱歉,物品发放失败!"); } } else { Msg.Box.Show(msg); } }
/// <summary> /// 发放物品 /// </summary> /// <returns></returns> public static bool UseCodes(Entity.GoodsCode gc, out string msg) { if (DAL.GoodsDAL.SearchCode(gc) == false) { msg = "抱歉,您输入的领取码不存在!"; return(false); } else if (DAL.GoodsDAL.IfUse(gc) == true) { System.Data.DataTable dt = DAL.GoodsDAL.CoedInfo(gc); msg = "是否确认发放 物品【" + dt.Rows[0][0].ToString() + "】 数量【" + dt.Rows[0][1].ToString() + "】 ?"; return(true); } else if (DAL.GoodsDAL.IfUse(gc) == false) { msg = "抱歉,该领取码已被使用!"; return(false); } else { msg = ""; return(false); } }
/// <summary> /// 未使用领取码 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static DataTable CodesList(Entity.GoodsCode gc) { string sql = "select GCID from GoodsCode where PID=" + gc.pID + " and GCState='未领取'"; return(DBHelper.GetDT(sql)); }
/// <summary> /// 查询物品领取码 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static int SearchGC(Entity.GoodsCode gc) { string sql = "select top 1 GCID from GoodsCode where PID=" + gc.pID + " order by GCTime DESC"; return((int)DBHelper.GetScalar(sql)); }
/// <summary> /// 添加申请记录 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static int AddCode(Entity.GoodsCode gc) { string sql = "insert into GoodsCode values(" + gc.pID + "," + gc.gID + "," + gc.gcCount + ",'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','未领取')"; return(DBHelper.GetLine(sql)); }
/// <summary> /// 查找物品编码 /// </summary> /// <returns></returns> public static int SearchCode(Entity.GoodsCode gc) { string sql = "select COUNT(*) from Goods where GID=" + gc.gID + ""; return((int)DBHelper.GetScalar(sql)); }
/// <summary> /// 查询发放信息 /// </summary> /// <param name="gc"></param> public static System.Data.DataTable CoedInfo(Entity.GoodsCode gc) { string sql = "select GName,GCCount from Goods,GoodsCode where Goods.GID=GoodsCode.GID and GcID=" + gc.gcID + ""; return(DBHelper.GetDT(sql)); }
/// <summary> /// 更新状态 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static int UpCode(Entity.GoodsCode gc) { string sql = "update GoodsCode set GCState='已使用' where GCID=" + gc.gcID + ""; return((int)DBHelper.GetLine(sql)); }