public GeneralAgreementViewModel GetGAByID(int?id) { SamajkalyanEntities ent = new SamajkalyanEntities(); GeneralAgreementViewModel entity = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == id).Select(x => new GeneralAgreementViewModel() { GeneralAgreement_ID = x.GeneralAgreement_ID, Name_Of_Ingo = x.Name_Of_Ingo, Name_of_Ingo_Nepali = x.Name_of_Ingo_Nepali, Ga_Date = x.Ga_Date, Ga_Date_Nepali = x.Ga_Date_Nepali, Period = x.Period, Pre_Annum_Commitment_Amount = x.Pre_Annum_Commitment_Amount, Ga_Service_Charge = x.Ga_Service_Charge, Sector = x.Sector, Hq_Address = x.Hq_Address, Contact_Person = x.Contact_Person, Country_Official_Nepal_Address = x.Country_Official_Nepal_Address, Contact_Number = x.Contact_Number, Email = x.Email, GA_TerminationDate = x.GA_TerminationDate, Ga_TerminationDate_Nepali = x.Ga_TerminationDate_Nepali, PA_Attachment_Location = x.PA_Attachment_Location, Scan_GA_Location = x.Scan_GA_Location, Country = x.Country, DeletedBy = x.DeletedBy, UpdatedBy = x.UpdatedBy, UpdatedDate = x.UpdatedDate, CreatedDate = DateTime.Now, }).FirstOrDefault(); return(entity); }
public ActionResult InsertUpdateGeneralAgreement(int?id) { GeneralAgreementViewModel model = new GeneralAgreementViewModel(); if (id > 0) { // GeneralAgreementViewModel model = pro.InsertGeneralAgreement(id ?? 0); if (id == null) { string[] stringarray = new string[] { }; } if (id != null) { string[] stringarray = new string[] { }; model = pro.GetGAByID(id); if (model.Scan_GA_Location != null) { stringarray = model.Scan_GA_Location.Split('_'); model.Scan_GA_Name = stringarray[1].ToString(); } return(View(model)); } } // return View(new DeploymentModel()); return(View(model)); //return View(model); }
public ActionResult GaReport() { GeneralAgreementViewModel model = new GeneralAgreementViewModel(); model.GeneralAgreementViewModelList = gpro.GetGAList(); return(View(model)); }
public bool InsertGeneralAgreement(GeneralAgreementViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { var GAEntity = new GeneralAgreement() { // Ethnic_ID = model.Ethnic_ID, Name_Of_Ingo = model.Name_Of_Ingo, Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali, Ga_Date = model.Ga_Date, Ga_Date_Nepali = model.Ga_Date_Nepali, Period = model.Period, Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount, Ga_Service_Charge = model.Ga_Service_Charge, Sector = model.Sector, Hq_Address = model.Hq_Address, Contact_Person = model.Contact_Person, Country_Official_Nepal_Address = model.Country_Official_Nepal_Address, Contact_Number = model.Contact_Number, Email = model.Email, GA_TerminationDate = model.GA_TerminationDate, Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali, PA_Attachment_Location = model.PA_Attachment_Location, Scan_GA_Location = model.Scan_GA_Location, CreatedBy = model.CreatedBy, DeletedBy = model.DeletedBy, UpdatedBy = model.UpdatedBy, UpdatedDate = model.UpdatedDate, CreatedDate = DateTime.Now, }; ent.GeneralAgreements.Add(GAEntity); int i = ent.SaveChanges(); if (i > 0) { return(true); } else { return(false); } } }
public bool InsertGeneralAgreement2(GeneralAgreementViewModel model) { using (SamajkalyanEntities ent = new SamajkalyanEntities()) { try { var generalAgreementRow = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).FirstOrDefault(); //_context.Database.Connection.Open(); //_context.Database.Connection.BeginTransaction(); if (generalAgreementRow == null) { generalAgreementRow = new GeneralAgreement(); } ; generalAgreementRow.Name_Of_Ingo = model.Name_Of_Ingo; generalAgreementRow.Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali; generalAgreementRow.Ga_Date = model.Ga_Date; generalAgreementRow.Ga_Date_Nepali = model.Ga_Date_Nepali; generalAgreementRow.Period = model.Period; generalAgreementRow.Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount; generalAgreementRow.Ga_Service_Charge = model.Ga_Service_Charge; generalAgreementRow.Sector = model.Sector; generalAgreementRow.Hq_Address = model.Hq_Address; generalAgreementRow.Contact_Person = model.Contact_Person; generalAgreementRow.Country_Official_Nepal_Address = model.Country_Official_Nepal_Address; generalAgreementRow.Contact_Number = model.Contact_Number; generalAgreementRow.Email = model.Email; generalAgreementRow.GA_TerminationDate = model.GA_TerminationDate; generalAgreementRow.Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali; generalAgreementRow.Scan_GA_Location = model.Scan_GA_Location; generalAgreementRow.PA_Attachment_Location = model.PA_Attachment_Location; generalAgreementRow.Country = model.Country; //deploymentRow.Status = true; if (model.GeneralAgreement_ID == 0) { // generalAgreementRow.Status = false; ent.GeneralAgreements.Add(generalAgreementRow); ent.SaveChanges(); } else { // deploymentRow.Status = dmodel.Status ?? false; ent.GeneralAgreements.Attach(generalAgreementRow); ent.Entry(generalAgreementRow).State = EntityState.Modified; ent.SaveChanges(); } if (model.GeneralAgreement_ID <= 0) { model.GeneralAgreement_ID = ent.Database.SqlQuery <GeneralAgreementViewModel>("select * from GeneralAgreement where GeneralAgreement_ID=(select max (GeneralAgreement_ID) from GeneralAgreement )").ToList().FirstOrDefault().GeneralAgreement_ID; //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId; } // #region files // using (var tempContext = new SamajkalyanEntities()) // { // var deletelist = tempContext.GA_Attachment.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).ToList(); // if (deletelist.Count > 0) // { // foreach (var item in deletelist) // { // if (model.GaAttachmentViewModelList == null) // { // model.GaAttachmentViewModelList = new List<GaAttachmentViewModel>(); // } // var isExists = model.GaAttachmentViewModelList.Where(x => x.GA_Attachment_ID == item.GeneralAgreement_ID).FirstOrDefault(); // if (isExists == null) // { // tempContext.GA_Attachment.Remove(item); // tempContext.SaveChanges(); // } // } // } // } // if (model.GaAttachmentViewModelList != null) // { // foreach (var item in model.GaAttachmentViewModelList) // { // GA_Attachment newRow = new GA_Attachment(); // newRow.GeneralAgreement_ID = model.GeneralAgreement_ID; // newRow.GA_Attachment_ID = item.GA_Attachment_ID; // newRow.PA_Attachment_Location = item.PA_Attachment_Location; // newRow.Scan_GA_Location = item.Scan_GA_Location; // //newRow.NoOfDep = item.NoOfDep; // if (item.GA_Attachment_ID == 0) // { // ent.GA_Attachment.Add(newRow); // ent.SaveChanges(); // } // else // { // ent.GA_Attachment.Attach(newRow); // ent.Entry(newRow).State = EntityState.Modified; // ent.SaveChanges(); // } // } // } } catch (Exception ex) { return(false); } } return(true); }
public ActionResult InsertUpdateGeneralAgreement(GeneralAgreementViewModel model) { try { //var result = depl.InsertUpdateEmployee(empModel); HttpPostedFileBase Scan_GA; HttpPostedFileBase PA_Attachment; string fileScanGA = ""; string filePA_Attachment = ""; int permittedSizeInBytes = 5 * 1024 * 1024; var filenamelen = 50; string filename; if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { //region image #region Ga Scan //var a = model.Scan_GA_Change; //if (a != null && Request.Files["Scan_GA"] != null) //{ //} //if (a && Request.Files["Scan_GA"] != null) //{ //} //if (Request.Files["Scan_GA"] !=null) //{ //} if (model.Scan_GA_Change != null && Request.Files["Scan_GA"] != null) { Scan_GA = Request.Files["Scan_GA"]; if (Scan_GA.ContentLength > permittedSizeInBytes) { //model.Msg = "Images sizes exced 5mb"; //model.Success = false; //return Json(rModel, JsonRequestBehavior.AllowGet); return(null); } else { filename = Path.GetFileName(Scan_GA.FileName); if (filename.Length > filenamelen) { filename = filename.Substring(filename.Length - filenamelen, filenamelen); } string nonReplaceStringFile = Guid.NewGuid().ToString() + "_" + filename; fileScanGA = Regex.Replace(nonReplaceStringFile, @"-", ""); string imagepath = @"~/Content/Attachment/" + fileScanGA; try { System.IO.File.Delete(Server.MapPath(@"~" + model.Scan_GA_Name)); } catch (Exception ex) { //throw; } Scan_GA.SaveAs(Server.MapPath(imagepath)); model.Scan_GA_Location = @"/Content/Attachment/" + fileScanGA; } } } #endregion var result = pro.InsertGeneralAgreement2(model); if (result == true) { TempData["SuccessMsg"] = "सफल भयो"; return(RedirectToAction("Index")); } } catch (Exception ex) { TempData["Msg"] = "असफल भयो "; return(View()); } return(View()); }
public ActionResult Details(int id) { GeneralAgreementViewModel abc = pro.GetGAByID(id); return(PartialView(abc)); }