public static bool updateLot(Lots lot) { try { List<SqlParameter> prams = new List<SqlParameter>(); using (DbManager Db = DbManager.GetDbManager()) { prams.Add(Db.MakeInParam("@LotId", SqlDbType.Int, 4, lot.LotId)); prams.Add(Db.MakeInParam("@LotNumber", SqlDbType.NVarChar, 10, lot.LotNumber)); prams.Add(Db.MakeInParam("@Quantity", SqlDbType.Int, 4, lot.Quantity)); prams.Add(Db.MakeInParam("@OrganizationId", SqlDbType.Int, 4, lot.OrganizationId)); prams.Add(Db.MakeInParam("@DateCreated", SqlDbType.DateTime, 8, lot.DateCreated)); prams.Add(Db.MakeInParam("@IsActive", SqlDbType.Bit, 0, lot.IsActive)); prams.Add(Db.MakeInParam("@SpaceId", SqlDbType.Int, 4, lot.SpaceId)); prams.Add(Db.MakeInParam("@UserID", SqlDbType.Int, 4, lot.UserID)); prams.Add(Db.MakeInParam("@RoleID", SqlDbType.Int, 4, lot.RoleID)); prams.Add(Db.MakeInParam("@bitCompleted", SqlDbType.Bit, 0, lot.IsCompleted)); prams.Add(Db.MakeInParam("@pintBarCodeId", SqlDbType.Int, 4, lot.BarCodeNumber)); int exec = Db.RunProc("[up_LotsInsertUpdate]", prams.ToArray()); return true; } } catch (Exception ex) { new SqlLog().InsertSqlLog(0, "LotsInfo UpdateLot", ex); } return false; }
public static string insertLot(Lots lot, out int Id, string guid, int facilityId = 0) { Id = 0; try { string lotId; List<SqlParameter> prams = new List<SqlParameter>(); using (DbManager Db = DbManager.GetDbManager()) { if (!string.IsNullOrEmpty(lot.LotNumber)) prams.Add(Db.MakeInParam("@LotNumber", SqlDbType.NVarChar, 100, lot.LotNumber)); if (lot.Quantity > 0) prams.Add(Db.MakeInParam("@Quantity", SqlDbType.Int, 4, lot.Quantity)); prams.Add(Db.MakeInParam("@OrganizationId", SqlDbType.Int, 4, lot.OrganizationId)); if (facilityId == 0) prams.Add(Db.MakeInParam("@intfacilityid", SqlDbType.Int, 0, DBNull.Value)); else prams.Add(Db.MakeInParam("@intfacilityid", SqlDbType.Int, 0, facilityId)); prams.Add(Db.MakeInParam("@DateCreated", SqlDbType.DateTime, 8, lot.DateCreated)); prams.Add(Db.MakeInParam("@IsActive", SqlDbType.Bit, 0, lot.IsActive)); if (lot.SpaceId > 0) prams.Add(Db.MakeInParam("@SpaceId", SqlDbType.Int, 4, lot.SpaceId)); if (lot.Permanent) prams.Add(Db.MakeInParam("@bitPermanent", SqlDbType.Bit, 0, lot.Permanent)); prams.Add(Db.MakeInParam("@UserID", SqlDbType.Int, 4, lot.UserID)); prams.Add(Db.MakeInParam("@RoleID", SqlDbType.Int, 4, lot.RoleID)); prams.Add(Db.MakeInParam("@bitCompleted", SqlDbType.Bit, 0, lot.IsCompleted)); prams.Add(Db.MakeInParam("@bitSubLot", SqlDbType.Bit, 0, lot.SubLot)); prams.Add(Db.MakeInParam("@pintBarCodeId", SqlDbType.Int, 4, lot.BarCodeId)); prams.Add(Db.MakeInParam("@vchrGuid", SqlDbType.NVarChar, 500, guid)); prams.Add(Db.MakeInParam("@intProductCatId", SqlDbType.Int, 4, lot.ProductCategoryId)); DataTable dt = Db.GetDataSet("up_LotsInsertUpdate", prams.ToArray()).Tables[0]; Id = Convert.ToInt32(dt.Rows[0]["LotId"]); return dt.Rows[0]["SerialNumber"].ToString(); } } catch (Exception ex) { new SqlLog().InsertSqlLog(0, "LotsInfo InsertLot", ex); } return null; }