public ActionResult showAllRecords() { List <OrganizationAccountEntity> AccDetails = null; OrganizationAccountEntity currentAccount = new OrganizationAccountEntity(); try { if (ViewBag.currentRecord != null) { currentAccount = ViewBag.currentRecord; ViewBag.currentRecord = null; } else { var objDtl = new OrganizationAccountComponent(); AccDetails = objDtl.GetOrganizationAccounts(); currentAccount = AccDetails.FirstOrDefault(); } } catch (Exception ex) { return(null); } return(View(currentAccount)); }
public JsonResult GetOrganizationAccountByID(int catID) { OrganizationAccountEntity AccDetails = null; try { var objDtl = new OrganizationAccountComponent(); AccDetails = objDtl.GetOrganizationAccountByID(catID); } catch (Exception ex) { return(null); } return(Json(AccDetails, JsonRequestBehavior.AllowGet)); }
public ActionResult BrowseAccountRecords(int id, string navigation) { OrganizationAccountEntity currentRecord = null; try { var objDtl = new OrganizationAccountComponent(); currentRecord = objDtl.BrowseAccountRecords(id, navigation); ViewBag.currentRecord = currentRecord; } catch (Exception ex) { return(null); } return(View("showAllRecords")); }
public string CreateOrganizationAccount(OrganizationAccountEntity AccDtl) { string strResponse = string.Empty; string fileExtension = string.Empty; var orgcomponent = new OrganizationAccountComponent(); string imgcrop = AccDtl.imgCropped; UserSessionInfo objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = objSessioninfo.UserId; AccDtl.Acc_CreatedBy = _userID; string imagename = string.Empty; if (AccDtl.Acc_CompanyLogo == "undefined") { AccDtl.Acc_CompanyLogo = "User.png"; } else if (AccDtl.imgCropped != "undefined") { byte[] bytes = Convert.FromBase64String(AccDtl.imgCropped.Split(',')[1]); string sourceFile = ""; string filePath = String.Empty; string base64 = AccDtl.imgCropped; filePath = "/uploadimages/Images/thumb/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".png"; sourceFile = filePath.Replace("/uploadimages/Images/thumb/", "").ToString(); using (FileStream stream = new FileStream(Server.MapPath(filePath), FileMode.Create)) { stream.Write(bytes, 0, bytes.Length); stream.Flush(); } string physicalPath = Server.MapPath("/uploadimages/Images/thumb/" + sourceFile); var path = Path.Combine(Server.MapPath("~" + @"\upload\topic\"), sourceFile); fileExtension = Path.GetExtension(path).ToLower(); imagename = sourceFile; AccDtl.Acc_CompanyLogo = imagename; } else if (Request.Files.Count > 0) { var file = Request.Files[0]; var fileName = "/uploadimages/images/thumb/" + file.FileName; imagename = file.FileName; var imagepath = Server.MapPath(fileName); file.SaveAs(imagepath); //UploadImage.Crop(100, 100, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/images/thumb/") + file.FileName)); } if (imagename == "") { AccDtl.Acc_CompanyLogo = "User.png"; } else { AccDtl.Acc_CompanyLogo = imagename; } #region MyRegion //string imagename = string.Empty; //string base64 = AccDtl.imgCropped; // if (Request.Files.Count > 0) //{ // var file = Request.Files[0]; // var fileName = "/uploadimages/images/" + file.FileName; // imagename = file.FileName; // var imagepath = Server.MapPath(fileName); // file.SaveAs(imagepath); // UploadImage.Crop(100, 100, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/images/thumb/") + file.FileName)); // // UploadImage.Crop( 240,180, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/Images/thumb/") + file.FileName)); //} //if (imagename == "") //{ // AccDtl.Acc_CompanyLogo = "User.png"; //} //else //{ // AccDtl.Acc_CompanyLogo = imagename; //} #endregion int r = orgcomponent.AddOrganizationAccount(AccDtl); if (r == 1) { strResponse = "Account created successfully"; } else if (r == 0) { strResponse = "Account already exists"; } else if (r == -1) { strResponse = "Please Fill Mandatory Fields"; } else if (r == 2) { strResponse = "AccountName already exists"; } else if (r == 3) { strResponse = "AccountCode already exists"; } //else if (r == 4) //{ // strResponse = "AccountCode already exists"; //} return(strResponse); }
public string UpdateOrganizationAccount(OrganizationAccountEntity accdtl) { string fileExtension = string.Empty; var orgcomponent = new OrganizationAccountComponent(); UserSessionInfo objSessioninfo = Session["UserSessionInfo"] as UserSessionInfo; int _userID = objSessioninfo.UserId; accdtl.Acc_ModifiedBy = _userID; string imagename = string.Empty; #region MyRegion //if (accdtl.imgCropped != "undefined") //{ // byte[] bytes = Convert.FromBase64String(accdtl.imgCropped.Split(',')[1]); // string sourceFile = ""; // string filePath = String.Empty; // string base64 = accdtl.imgCropped; // filePath = "/uploadimages/Images/thumb/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".png"; // sourceFile = filePath.Replace("/uploadimages/Images/thumb/", "").ToString(); // using (FileStream stream = new FileStream(Server.MapPath(filePath), FileMode.Create)) // { // stream.Write(bytes, 0, bytes.Length); // stream.Flush(); // } // string physicalPath = Server.MapPath("/uploadimages/Images/thumb/" + sourceFile); // imagename = sourceFile; // accdtl.Acc_CompanyLogo = imagename; //} //else if (Request.Files.Count > 0) //{ // var file = Request.Files[0]; // //if (file != null) // //{ // var fileName = "/uploadimages/Images/thumb/" + file.FileName; // imagename = file.FileName; // var imagepath = Server.MapPath(fileName); // file.SaveAs(imagepath); // //} // //else // //{ // // imagename = accdtl.Acc_CompanyLogo; // //} // // UploadImage.Crop(240,180, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/Images/thumb/") + file.FileName)); // //UploadImage.Crop(100, 100, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/images/thumb/") + file.FileName)); //} //else //{ // accdtl.Acc_CompanyLogo = "User.png"; //} #endregion if (accdtl.Acc_CompanyLogo == "undefined") { accdtl.Acc_CompanyLogo = "User.png"; } else if (accdtl.imgCropped != "undefined") { byte[] bytes = Convert.FromBase64String(accdtl.imgCropped.Split(',')[1]); string sourceFile = ""; string filePath = String.Empty; string base64 = accdtl.imgCropped; filePath = "/uploadimages/Images/thumb/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".png"; sourceFile = filePath.Replace("/uploadimages/Images/thumb/", "").ToString(); using (FileStream stream = new FileStream(Server.MapPath(filePath), FileMode.Create)) { stream.Write(bytes, 0, bytes.Length); stream.Flush(); } string physicalPath = Server.MapPath("/uploadimages/Images/thumb/" + sourceFile); var path = Path.Combine(Server.MapPath("~" + @"\upload\topic\"), sourceFile); fileExtension = Path.GetExtension(path).ToLower(); imagename = sourceFile; accdtl.Acc_CompanyLogo = imagename; } else if (Request.Files.Count > 0) { var file = Request.Files[0]; var fileName = "/uploadimages/images/thumb/" + file.FileName; imagename = file.FileName; var imagepath = Server.MapPath(fileName); file.SaveAs(imagepath); //UploadImage.Crop(100, 100, file.InputStream, Path.Combine(Server.MapPath("~/uploadimages/images/thumb/") + file.FileName)); } else { imagename = accdtl.Acc_CompanyLogo; } accdtl.Acc_CompanyLogo = imagename; string response = orgcomponent.UpdateOrganizationAccount(accdtl); return(response); }
public string UpdateAccountDetail(OrganizationAccountEntity ctDtl) { Account AccountDtl = null; History_Account _AccountHistory = new History_Account(); string response = string.Empty; using (var db = new DbContext(CONNECTION_NAME)) { try { AccountDtl = db.Set <Account>().Where(s => s.Acc_AccountID == ctDtl.Acc_AccountID).FirstOrDefault <Account>(); Account orgCheck = db.Set <Account>().Where(s => (s.Acc_AccountName == ctDtl.Acc_AccountName && s.Acc_isDeleted == false && s.Acc_AccountID != ctDtl.Acc_AccountID)).FirstOrDefault <Account>(); Account CodeCheck = db.Set <Account>().Where(s => (s.Acc_AccountCode == ctDtl.Acc_AccountCode && s.Acc_isDeleted == false && s.Acc_AccountID != ctDtl.Acc_AccountID)).FirstOrDefault <Account>(); if (orgCheck != null) { return(response = "AccountName already exists"); } if (CodeCheck != null) { return(response = "AccountCode already exists"); } if (AccountDtl != null) { AccountDtl.Acc_AccountCode = ctDtl.Acc_AccountCode; AccountDtl.Acc_AccountDescription = ctDtl.Acc_AccountDescription; AccountDtl.Acc_AccountName = ctDtl.Acc_AccountName; AccountDtl.Acc_CompanyLogo = ctDtl.Acc_CompanyLogo.Replace(" ", "%20"); AccountDtl.Acc_EmailID = ctDtl.Acc_EmailID; AccountDtl.Acc_MobileNumber = ctDtl.Acc_MobileNumber; AccountDtl.Acc_PhoneNumber = ctDtl.Acc_PhoneNumber; AccountDtl.Acc_isDeleted = ctDtl.Acc_isDeleted; AccountDtl.Acc_Version = ctDtl.Acc_Version; AccountDtl.Acc_ModifiedBy = ctDtl.Acc_ModifiedBy; AccountDtl.Acc_ModifiedDate = System.DateTime.Now; // AccountDtl.Acc_isDeleted = false; AccountDtl.is_UsAccount = ctDtl.is_UsAccount; } db.SaveChanges(); int id = AccountDtl.Acc_AccountID; Conn = new SqlConnection(str); if (AccountDtl.is_pre_requisite == false) { if (ctDtl.is_pre_requisite == true) { Account acc = db.Set <Account>().Where(s => s.Acc_AccountID == id).FirstOrDefault <Account>(); acc.is_pre_requisite = true; db.SaveChanges(); if (Conn.State != System.Data.ConnectionState.Open) { Conn.Open(); } SqlCommand objCommand = new SqlCommand("[CreateDefaultRoles]", Conn); objCommand.CommandType = CommandType.StoredProcedure; objCommand.Parameters.AddWithValue("@AccountID", id); objCommand.ExecuteNonQuery(); } } response = "Account Successfully Updated"; } catch (Exception ex) { throw ex; } return(response); } }
public OrganizationAccountEntity BrowseAccountRecords(int id, string navigation) { OrganizationAccountEntity record = null; using (var db = new EvolutyzCornerDataEntities()) { try { if (navigation.ToUpper() == "FIRST") { record = (from q in db.Accounts orderby q.Acc_AccountID ascending select new OrganizationAccountEntity { Acc_AccountID = q.Acc_AccountID, Acc_AccountCode = q.Acc_AccountCode, Acc_AccountName = q.Acc_AccountName, Acc_AccountDescription = q.Acc_AccountDescription, Acc_EmailID = q.Acc_EmailID, Acc_MobileNumber = q.Acc_MobileNumber, Acc_PhoneNumber = q.Acc_PhoneNumber, Acc_CompanyLogo = q.Acc_CompanyLogo.Replace(" ", "%20"), Acc_ActiveStatus = q.Acc_ActiveStatus, Acc_Version = q.Acc_Version, Acc_CreatedBy = q.Acc_CreatedBy, Acc_CreatedDate = q.Acc_CreatedDate, Acc_ModifiedBy = q.Acc_ModifiedBy, Acc_ModifiedDate = q.Acc_ModifiedDate, Acc_isDeleted = q.Acc_isDeleted, }).FirstOrDefault(); } else if (navigation.ToUpper() == "LAST") { record = (from q in db.Accounts orderby q.Acc_AccountID descending select new OrganizationAccountEntity { Acc_AccountID = q.Acc_AccountID, Acc_AccountCode = q.Acc_AccountCode, Acc_AccountName = q.Acc_AccountName, Acc_AccountDescription = q.Acc_AccountDescription, Acc_EmailID = q.Acc_EmailID, Acc_MobileNumber = q.Acc_MobileNumber, Acc_PhoneNumber = q.Acc_PhoneNumber, Acc_CompanyLogo = q.Acc_CompanyLogo.Replace(" ", "%20"), Acc_ActiveStatus = q.Acc_ActiveStatus, Acc_Version = q.Acc_Version, Acc_CreatedBy = q.Acc_CreatedBy, Acc_CreatedDate = q.Acc_CreatedDate, Acc_ModifiedBy = q.Acc_ModifiedBy, Acc_ModifiedDate = q.Acc_ModifiedDate, Acc_isDeleted = q.Acc_isDeleted, }).FirstOrDefault(); } else if (navigation.ToUpper() == "NEXT") { record = (from q in db.Accounts where q.Acc_AccountID >= id orderby q.Acc_AccountID ascending select new OrganizationAccountEntity { Acc_AccountID = q.Acc_AccountID, Acc_AccountCode = q.Acc_AccountCode, Acc_AccountName = q.Acc_AccountName, Acc_AccountDescription = q.Acc_AccountDescription, Acc_EmailID = q.Acc_EmailID, Acc_MobileNumber = q.Acc_MobileNumber, Acc_PhoneNumber = q.Acc_PhoneNumber, Acc_CompanyLogo = q.Acc_CompanyLogo.Replace(" ", "%20"), Acc_ActiveStatus = q.Acc_ActiveStatus, Acc_Version = q.Acc_Version, Acc_CreatedBy = q.Acc_CreatedBy, Acc_CreatedDate = q.Acc_CreatedDate, Acc_ModifiedBy = q.Acc_ModifiedBy, Acc_ModifiedDate = q.Acc_ModifiedDate, Acc_isDeleted = q.Acc_isDeleted, }).Skip(1).FirstOrDefault(); } else if (navigation.ToUpper() == "PREVIOUS") { record = (from q in db.Accounts where q.Acc_AccountID < id orderby q.Acc_AccountID ascending select new OrganizationAccountEntity { Acc_AccountID = q.Acc_AccountID, Acc_AccountCode = q.Acc_AccountCode, Acc_AccountName = q.Acc_AccountName, Acc_AccountDescription = q.Acc_AccountDescription, Acc_EmailID = q.Acc_EmailID, Acc_MobileNumber = q.Acc_MobileNumber, Acc_PhoneNumber = q.Acc_PhoneNumber, Acc_CompanyLogo = q.Acc_CompanyLogo.Replace(" ", "%20"), Acc_ActiveStatus = q.Acc_ActiveStatus, Acc_Version = q.Acc_Version, Acc_CreatedBy = q.Acc_CreatedBy, Acc_CreatedDate = q.Acc_CreatedDate, Acc_ModifiedBy = q.Acc_ModifiedBy, Acc_ModifiedDate = q.Acc_ModifiedDate, Acc_isDeleted = q.Acc_isDeleted, }).FirstOrDefault(); } return(record); } catch (Exception ex) { return(record); } } }
public int AddOrganizationAccount(OrganizationAccountEntity orgDtl) { Account orgCheck = new Account(); Account CodeCheck = new Account(); int retVal = 0; string response = string.Empty; using (var db = new DbContext(CONNECTION_NAME)) { try { orgCheck = db.Set <Account>().Where(s => (s.Acc_AccountName == orgDtl.Acc_AccountName && s.Acc_isDeleted == false)).FirstOrDefault <Account>(); CodeCheck = db.Set <Account>().Where(s => (s.Acc_AccountCode == orgDtl.Acc_AccountCode && s.Acc_isDeleted == false)).FirstOrDefault <Account>(); if (orgCheck != null) { return(retVal = 2); } if (CodeCheck != null) { return(retVal = 3); } Account OrgCheck = new Account(); OrgCheck.Acc_AccountID = orgDtl.Acc_AccountID; OrgCheck.Acc_AccountCode = orgDtl.Acc_AccountCode; OrgCheck.Acc_AccountName = orgDtl.Acc_AccountName; OrgCheck.Acc_AccountDescription = orgDtl.Acc_AccountDescription; // OrgCheck.Acc_EmailID = orgDtl.Acc_EmailID; // OrgCheck.Acc_MobileNumber = orgDtl.Acc_MobileNumber; // OrgCheck.Acc_PhoneNumber = orgDtl.Acc_PhoneNumber; OrgCheck.Acc_CompanyLogo = orgDtl.Acc_CompanyLogo.Replace(" ", "%20"); OrgCheck.Acc_isDeleted = orgDtl.Acc_isDeleted; // orgCheck.//Acc_Version = orgDtl.Acc_Version, OrgCheck.Acc_CreatedBy = orgDtl.Acc_CreatedBy; OrgCheck.Acc_CreatedDate = System.DateTime.Now; // OrgCheck.Acc_isDeleted = false; OrgCheck.is_UsAccount = orgDtl.is_UsAccount; db.Set <Account>().Add(OrgCheck); db.SaveChanges(); int id = OrgCheck.Acc_AccountID; Conn = new SqlConnection(str); if (orgDtl.is_pre_requisite == true) { Account acc = db.Set <Account>().Where(s => s.Acc_AccountID == id).FirstOrDefault <Account>(); acc.is_pre_requisite = true; db.SaveChanges(); if (Conn.State != System.Data.ConnectionState.Open) { Conn.Open(); } SqlCommand objCommand = new SqlCommand("[CreateDefaultRoles]", Conn); objCommand.CommandType = CommandType.StoredProcedure; objCommand.Parameters.AddWithValue("@AccountID", id); objCommand.ExecuteNonQuery(); } retVal = 1; } catch (Exception ex) { retVal = -1; } } return(retVal); }
public int AddOrganizationAccount(OrganizationAccountEntity orgAccount) { var organizationAccountDAC = new OrganizationAccountDAC(); return(organizationAccountDAC.AddOrganizationAccount(orgAccount)); }
public string UpdateOrganizationAccount(OrganizationAccountEntity orgAccount) { var organizationAccountDAC = new OrganizationAccountDAC(); return(organizationAccountDAC.UpdateAccountDetail(orgAccount)); }