public ActionResult Edit(Stockpoint model) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new StockpointRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "StockPoint", "StockPointName", model.StockPointName, "StockPointId", model.StockPointId); if (!isexists) { var result = new StockpointRepository().UpdateStockpoint(model); if (result.StockPointId > 0) { TempData["Success"] = "Updated Successfully!"; TempData["RefNo"] = result.StockPointRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["RefNo"] = null; return(View("Create", model)); } }
public ActionResult Create(Stockpoint model) { var repo = new StockpointRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "StockPoint", "StockPointName", model.StockPointName, null, null); if (!isexists) { var result = new StockpointRepository().InsertStockpoint(model); if (result.StockPointId > 0) { TempData["Success"] = "Added Successfully!"; TempData["RefNo"] = result.StockPointRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["RefNo"] = null; return(View("Create", model)); } }
public Stockpoint InsertStockpoint(Stockpoint model) { using (IDbConnection connection = OpenConnection(dataConnection)) { IDbTransaction trn = connection.BeginTransaction(); string sql = @"insert into StockPoint(StockPointRefNo,StockPointName,StockPointShrtName,StockPointDoorNo,StockPointZip,StockPointArea, StockPointPhone,StockPointCity,StockPointFax,CreatedBy,CreatedDate,OrganizationId) Values (@StockPointRefNo,@StockPointName,@StockPointShrtName,@StockPointDoorNo,@StockPointZip, @StockPointArea,@StockPointPhone,@StockPointCity,@StockPointFax,@CreatedBy,getDate(),@OrganizationId); SELECT CAST(SCOPE_IDENTITY() as int)"; int id = 0; try { int internalid = DatabaseCommonRepository.GetInternalIDFromDatabase(connection, trn, typeof(Stockpoint).Name, "0", 1); model.StockPointRefNo = "SP/" + internalid; id = connection.Query <int>(sql, model, trn).Single(); model.StockPointId = id; InsertLoginHistory(dataConnection, model.CreatedBy, "Create", "Stock Point", id.ToString(), "0"); trn.Commit(); } catch (Exception e) { trn.Rollback(); model.StockPointId = 0; model.StockPointRefNo = null; } return(model); } }
public ActionResult Delete(Stockpoint model) { var result = new StockpointRepository().DeleteStockpoint(model); if (result.StockPointId > 0) { TempData["Success"] = "Deleted Successfully!"; TempData["RefNo"] = model.StockPointRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } }
public Stockpoint UpdateStockpoint(Stockpoint model) { using (IDbConnection connection = OpenConnection(dataConnection)) { string sql = @"UPDATE Stockpoint SET StockPointName = @StockPointName , StockPointShrtName = @StockPointShrtName, StockPointDoorNo = @StockPointDoorNo, StockPointZip = @StockPointZip ,StockPointArea = @StockPointArea ,StockPointPhone = @StockPointPhone, StockPointCity = @StockPointCity, StockPointFax = @StockPointFax, CreatedBy = @CreatedBy,CreatedDate= GETDATE(),OrganizationId = @OrganizationId OUTPUT INSERTED.StockPointId WHERE StockPointId = @StockPointId"; try { var id = connection.Execute(sql, model); model.StockPointId = id; InsertLoginHistory(dataConnection, model.CreatedBy, "Update", "Stock Point", id.ToString(), "0"); } catch (Exception ex) { model.StockPointId = 0; } return(model); } }
public Stockpoint DeleteStockpoint(Stockpoint model) { using (IDbConnection connection = OpenConnection(dataConnection)) { string sql = @"UPDATE Stockpoint SET isActive = 0 OUTPUT INSERTED.StockPointId WHERE StockPointId = @StockPointId"; try { var id = connection.Execute(sql, model); model.StockPointId = id; InsertLoginHistory(dataConnection, model.CreatedBy, "Delete", "Stock Point", id.ToString(), "0"); } catch (Exception ex) { model.StockPointId = 0; } return(model); } }