/// <summary> /// get table record /// <summary> /// <param name=id>id</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of warehouseproductinout</returns> public modWarehouseProductInout GetItem(int?id, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select id,warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time from warehouse_product_inout where id={0} order by id", id); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modWarehouseProductInout model = new modWarehouseProductInout(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.WarehouseId = dalUtility.ConvertToString(rdr["warehouse_id"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormType = dalUtility.ConvertToString(rdr["form_type"]); model.InvNo = dalUtility.ConvertToString(rdr["inv_no"]); model.InoutDate = dalUtility.ConvertToDateTime(rdr["inout_date"]); model.StartQty = dalUtility.ConvertToString(rdr["start_qty"]); model.InputQty = dalUtility.ConvertToString(rdr["input_qty"]); model.OutputQty = dalUtility.ConvertToDecimal(rdr["output_qty"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); emsg = null; return(model); } else { emsg = "Error on read data"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// update a warehouseproductinout /// <summary> /// <param name=id>id</param> /// <param name=mod>model object of warehouseproductinout</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(int?id, modWarehouseProductInout mod, out string emsg) { try { string sql = string.Format("update warehouse_product_inout set warehouse_id='{0}',product_id='{1}',size='{2}',form_id='{3}',form_type='{4}',inv_no='{5}',inout_date='{6}',start_qty='{7}',input_qty='{8}',output_qty='{9}',remark='{10}',update_user='******',update_time=getdate() where id={12}", mod.WarehouseId, mod.ProductId, mod.Size, mod.FormId, mod.FormType, mod.InvNo, mod.InoutDate, mod.StartQty, mod.InputQty, mod.OutputQty, mod.Remark, mod.UpdateUser, id); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// insert a warehouseproductinout /// <summary> /// <param name=mod>model object of warehouseproductinout</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modWarehouseProductInout mod, out string emsg) { try { string sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", mod.WarehouseId, mod.ProductId, mod.Size, mod.FormId, mod.FormType, mod.InvNo, mod.InoutDate, mod.StartQty, mod.InputQty, mod.OutputQty, mod.Remark, mod.UpdateUser); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// get all warehouseproductinout /// <summary> /// <param name=fromdate>fromdate</param> /// <param name=todate>todate</param> /// <param name=out emsg>return error message</param> ///<returns>details of all warehouseproductinout</returns> public BindingCollection <modWarehouseProductInout> GetIList(string warehouselist, string productidlist, string productname, string sizelist, string formtypelist, string fromdate, string todate, out string emsg) { try { BindingCollection <modWarehouseProductInout> modellist = new BindingCollection <modWarehouseProductInout>(); //Execute a query to read the categories string warehousewhere = string.Empty; if (!string.IsNullOrEmpty(warehouselist) && warehouselist.CompareTo("ALL") != 0) { warehousewhere = "and a.warehouse_id in ('" + warehouselist.Replace(",", "','") + "') "; } string productidwhere = string.Empty; if (!string.IsNullOrEmpty(productidlist) && productidlist.CompareTo("ALL") != 0) { productidwhere = "and a.product_id in ('" + productidlist.Replace(",", "','") + "') "; } string productnamewhere = string.Empty; if (!string.IsNullOrEmpty(productname)) { productnamewhere = "and a.product_name like '%" + productname + "%' "; } string sizewhere = string.Empty; if (!string.IsNullOrEmpty(sizelist) && sizelist.CompareTo("ALL") != 0) { sizewhere = "and a.size in ('" + sizelist.Replace(",", "','") + "') "; } string formtypewhere = string.Empty; if (!string.IsNullOrEmpty(formtypelist) && formtypelist.CompareTo("ALL") != 0) { formtypewhere = "and a.form_type in ('" + formtypelist.Replace(",", "','") + "') "; } string inoutdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { inoutdatewhere = "and a.inout_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { inoutdatewhere += "and a.inout_date <= '" + Convert.ToDateTime(todate) + "' "; } string sql = "select a.id,a.warehouse_id,a.product_id,b.product_name,a.size,a.form_id,a.form_type,a.inv_no,a.inout_date,a.start_qty,a.input_qty,a.output_qty,a.remark,a.update_user,a.update_time " + "from warehouse_product_inout a inner join product_list b on a.product_id=b.product_id " + warehousewhere + productidwhere + productnamewhere + sizewhere + formtypewhere + inoutdatewhere + "order by a.id"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modWarehouseProductInout model = new modWarehouseProductInout(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.WarehouseId = dalUtility.ConvertToString(rdr["warehouse_id"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormType = dalUtility.ConvertToString(rdr["form_type"]); model.InvNo = dalUtility.ConvertToString(rdr["inv_no"]); model.InoutDate = dalUtility.ConvertToDateTime(rdr["inout_date"]); model.StartQty = dalUtility.ConvertToString(rdr["start_qty"]); model.InputQty = dalUtility.ConvertToString(rdr["input_qty"]); model.OutputQty = dalUtility.ConvertToDecimal(rdr["output_qty"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }