public int UpdateOutletRegister(OutletRegisterModel outletRegisterModel) { int result = 0; using (var connection = new SqlConnection(appSettings.GetConnectionString())) { connection.Open(); SqlTransaction sqltrans = connection.BeginTransaction(); var query = "EXEC pxOutletRegister 2, " + LoginDetail.OutletId + ", " + LoginDetail.UserId + ", NULL ;"; result = connection.Execute(query, outletRegisterModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }
public int UpdateOutletRegister(OutletRegisterModel OutletRegisterModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "UPDATE OutletRegister SET " + "OpeningBalance=@OpeningBalance, ApprovalUserId= " + LoginInfo.Userid + " ,ApprovalDateTime = GETDate() , " + " ApprovalNotes = @ApprovalNotes " + "WHERE Id = @Id;"; result = con.Execute(query, OutletRegisterModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }
public int InsertOutletRegister(OutletRegisterModel outletRegisterModel) { int result = 0; using (var connection = new SqlConnection(appSettings.GetConnectionString())) { connection.Open(); SqlTransaction sqltrans = connection.BeginTransaction(); var query = "EXEC pxOutletRegister 1,@OutletId,@UserId,@OpeningBalance"; result = connection.Execute(query, outletRegisterModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }
public int InsertOutletRegister(OutletRegisterModel outletRegisterModel) { int result = 0; if (Validation(outletRegisterModel) > 0) { return(result); } using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO OutletRegister" + "(OutletId,UserId,OpenDate,OpeningBalance) " + " VALUES " + "(@OutletId,@UserId,@OpenDate,@OpeningBalance); " + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, outletRegisterModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }
public ActionResult OutletRegister(OutletRegisterModel outletRegisterModel) { outletRegisterModel.OutletList = _iDropDownService.GetOutletList(); outletRegisterModel.UserList = _iDropDownService.GetUserList(); var errors = ModelState .Where(x => x.Value.Errors.Count > 0) .Select(x => new { x.Key, x.Value.Errors }) .ToArray(); decimal value; string errorString; if (decimal.TryParse(outletRegisterModel.OpeningBalance.ToString(), out value) == true) { if (value <= 0) { ModelState.AddModelError("OpeningBalance", "Opening balance should be more than zero"); } } if (!ModelState.IsValid) { errorString = this.ValidationOutletRegister(outletRegisterModel); if (!string.IsNullOrEmpty(errorString)) { ViewBag.Validate = errorString; return(View(outletRegisterModel)); } } if (outletRegisterModel.Id > 0) { var result = _iOutletRegisterService.UpdateOutletRegister(outletRegisterModel); ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss"); } else { var result = _iOutletRegisterService.InsertOutletRegister(outletRegisterModel); if (result == 0) { errorString = "User with outlet already exists for the same open date"; ModelState.AddModelError("UserId", "User with outlet already exists for the same open date"); ViewBag.Validate = errorString; return(View(outletRegisterModel)); } else { ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess"); } } return(RedirectToAction("Index", "OutletRegister")); }
public int Validation(OutletRegisterModel outletRegisterModel) { var name = ""; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { string query = "SELECT COUNT(*)" + " FROM OutletRegister " + " Where UserId = " + outletRegisterModel.UserId + " AND IsDeleted=0 AND ApprovalUserId IS Null AND convert(varchar(12),OpenDate,5) = '" + outletRegisterModel.OpenDate.ToString("dd-MM-yy") + " '" + " AND OutletId = " + outletRegisterModel.OutletId + " ;"; name = con.ExecuteScalar <string>(query); } return(Int16.Parse(name)); }
private string ValidationOutletRegister(OutletRegisterModel outletRegisterModel) { string ErrorString = string.Empty; if (string.IsNullOrEmpty(outletRegisterModel.OutletId.ToString())) { ErrorString = _locService.GetLocalizedHtmlString("ValidAddOnesName"); return(ErrorString); } if (string.IsNullOrEmpty(outletRegisterModel.UserId.ToString())) { ErrorString = _locService.GetLocalizedHtmlString("ValidAddOnesName"); return(ErrorString); } if (Math.Abs(outletRegisterModel.OpeningBalance) <= 0) { ErrorString = _locService.GetLocalizedHtmlString("ValidAddOnesName"); return(ErrorString); } return(ErrorString); }
public ActionResult OutletRegister(int?id) { OutletRegisterModel outletRegisterModel = new OutletRegisterModel(); if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true) { outletRegisterModel.OpenDate = DateTime.Now; if (id > 0) { int OutletRegisterId = Convert.ToInt32(id); outletRegisterModel = _iOutletRegisterService.GetOutletRegisterById(OutletRegisterId); } outletRegisterModel.OutletList = _iDropDownService.GetOutletList(); outletRegisterModel.UserList = _iDropDownService.GetUserList(); return(View(outletRegisterModel)); } else { return(RedirectToAction("NotFound", "Error")); } }
public int UpdateOutletRegister(OutletRegisterModel OutletRegisterModel) { return(_iOutletRegisterRepository.UpdateOutletRegister(OutletRegisterModel)); }
public int InsertOutletRegister(OutletRegisterModel OutletRegisterModel) { return(_iOutletRegisterRepository.InsertOutletRegister(OutletRegisterModel)); }