public ActionResult Edit(AD_Clients cl, List <AD_ClientContacts> con, List <AD_ClientAddress> add) { Response res = new Response(); string fname = string.Empty; try { if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = cl.ClientPrefix; } fname = Path.Combine(Server.MapPath("~/Content/Images/ClientLogo"), fname + "_logo." + Path.GetExtension(file.FileName)); file.SaveAs(fname); } } int Id = 0; ClientsBL rb = new ClientsBL(); cl.Logo = fname; Id = rb.Manage("Update", cl); dbDataTable ddt = new dbDataTable(); //DataTable dtcon = ddt.List(); //foreach (var item in con) //{ // myDataTable.AddRow(dtcon, "Value1", item.ContactPerson, "Value2", item.Designation, "Value3", item.Gender, "Value4", item.Title, "Value5", item.ContactNo, // "Value6", item.ContactType, "Value7", item.IsPrimary, "Value8", Id, "Value9", item.UserId, "Value10", item.RegionId, "Value11", item.CityId, "Value12", item.IsActive, "Value13", item.ReportToId, "Value14",item.ContactId); //} //AD_ClientContactsDL ccb = new AD_ClientContactsDL(); //AD_ClientContacts clobj = new AD_ClientContacts(); //ccb.Manage("UpdateBulk", dtcon); DataTable dt = ddt.List(); foreach (var item in add) { if (item.Address != null || item.Address != "") { myDataTable.AddRow(dt, "Value1", item.Address, "Value2", item.Street, "Value3", item.CityId, "Value4", item.StateId, "Value5", item.CountryId, "Value6", item.ZipCode, "Value7", item.IsHeadOffice, "Value8", Id, "Value9", item.IsActive, "Value10", item.AddressId); } } AD_ClientAddressDL classaddress = new AD_ClientAddressDL(); classaddress.Manage("UpdateBulk", dt); //res.Status = "success"; // res.Message = "save successfully"; TempData["msg_success"] = "Update successfully"; } catch (Exception ex) { // res.Status = "danger"; // res.Message = ex.Message; TempData["msg_error"] = ex.Message; } return(RedirectToAction("Edit", new { @Id = cl.ClientId })); //Json(res, JsonRequestBehavior.AllowGet); }
public int Manage(string filter, AD_ClientAddress cl) { return(cd.Manage(filter, cl.AddressId, cl.Address, cl.Street, cl.AddressCityId, cl.StateId, cl.CountryId, cl.ZipCode, cl.IsHeadOffice, cl.ClientId, cl.IsActive)); }
public ActionResult New(AD_Clients cl, List <AD_ClientContacts> con, List <AD_ClientAddress> add) { decimal Id = 0; Response res = new Response(); string fname = string.Empty; try { ClientsBL rb = new ClientsBL(); var List = rb.ToList("Company"); if (List.Count > 0) { res.Status = "danger"; res.Message = "Company Already Exist !"; return(Json(res, JsonRequestBehavior.AllowGet)); } string Extension = ""; if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = cl.ClientPrefix; } fname = Path.Combine(Server.MapPath("~/Content/Images/ClientLogo"), fname + "_logo" + Path.GetExtension(file.FileName)); file.SaveAs(fname); Extension = Path.GetExtension(file.FileName); } } cl.Logo = "/Content/Images/ClientLogo/" + cl.ClientPrefix + "_logo" + Extension; Id = rb.Manage("Insert", cl); dbDataTable ddt = new dbDataTable(); DataTable dtcon = ddt.List(); DataTable dt = ddt.List(); foreach (var item in add) { myDataTable.AddRow(dt, "Value1", item.Address, "Value2", item.Street, "Value3", item.CityId, "Value4", item.StateId, "Value5", item.CountryId, "Value6", item.ZipCode, "Value7", item.IsHeadOffice, "Value8", Id, "Value9", item.IsActive); } AD_ClientAddressDL claddress = new AD_ClientAddressDL(); claddress.Manage("Insert", dt); res.Status = "success"; res.Value = Id; res.Message = "Save successfully"; res.Value = Id.ToString(); } catch (Exception ex) { res.Status = "danger"; res.Message = ex.Message; } if (res.Status == "success") { return(Json(res, JsonRequestBehavior.AllowGet)); } else { return(Json(res, JsonRequestBehavior.AllowGet)); } }