//[ValidateAntiForgeryToken] public JsonResult Insert(EMPLOYEES eMPLOYEES) { try { //eMPLOYEES.EMP_H_DATE = new DateTime(); eMPLOYEES.FULL_NAME = eMPLOYEES.EMPLOYEE_FIRST_NAME; db.EMPLOYEES.Add(eMPLOYEES); db.SaveChanges(); SFncs.lom.Add(new SMessage { Stat = "success", SEM = "تم بنجاج" }); SFncs.lom.Add(new SMessage { Stat = "success", SEM = "تم بنجاج" }); } catch (Exception ex) { SFncs.lom.Add(new SMessage { Stat = "warning", SEM = ex.Message }); } return(Json(SFncs.lom, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateEmployee(EMPLOYEES employee) { var result = new JsonResult(); var validationFailures = new List <ValidationFailures>(); validationFailures = validateSave(employee).ToList(); if (validationFailures.Any()) { result = Json(new { failures = validationFailures[0].Message }); return(result); } else { var newEmployee = db.EMPLOYEES.SingleOrDefault(b => b.Id == employee.Id); if (newEmployee != null) { newEmployee.Name = employee.Name; newEmployee.Cpf = employee.Cpf; newEmployee.Phone = employee.Phone; newEmployee.FunctionId = employee.FunctionId; db.SaveChanges(); return(Json(new { success = true })); } } return(Json(new { Success = false })); }
public ActionResult PrintHistorique(string CIN) { EMPLOYEES Employee = BD.EMPLOYEES.Where(Emp => Emp.CIN == CIN).FirstOrDefault(); List <LIGNES_GENERATIONS> Liste = BD.LIGNES_GENERATIONS.Where(Emp => Emp.EMPLOYEES.ID == Employee.ID).ToList(); dynamic dt = from Element in Liste select new { CIN = Employee.CIN, FULLNAME = CleanString(Employee.FULLNAME), NUM_ASS_SOC = Employee.NUM_ASS_SOC, QUALIFICATION = Employee.QUALIFICATION, NUMERO = Employee.NUMERO, SOCIETE = Element.GENERATIONS.DECLARATIONS.SOCIETE, CODE = Element.GENERATIONS.CODE, TRIMESTRE = Element.GENERATIONS.TRIMESTRE, ANNEE = Element.GENERATIONS.ANNEE, SALAIRE_MOIS_3 = Element.SALAIRE_MOIS_3, SALAIRE_MOIS_2 = Element.SALAIRE_MOIS_2, SALAIRE_MOIS_1 = Element.SALAIRE_MOIS_1 }; ReportDocument rptH = new ReportDocument(); string FileName = Server.MapPath("/Reports/PRINT_HISTORIQUE_CNSS.rpt"); rptH.Load(FileName); rptH.SummaryInfo.ReportTitle = "Historique déclaration CNSS"; rptH.SetDataSource(dt); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
public ActionResult FormEmployee(string Mode, string Code, string Societe) { EMPLOYEES Employee = new EMPLOYEES(); if (Mode == "Create") { ViewBag.Type = "Nouveau Employee"; ViewBag.date = DateTime.Today.ToShortDateString(); } if (Mode == "Edit") { ViewBag.Type = "Modifier un Employee"; int ID = int.Parse(Code); Employee = BD.EMPLOYEES.Where(emp => emp.ID == ID).FirstOrDefault(); ViewBag.date = Employee.DEMARRAGE != null?Employee.DEMARRAGE.Value.ToShortDateString() : DateTime.Today.ToShortDateString(); } ViewBag.Code = Code; ViewBag.Mode = Mode; ViewBag.Societe = Societe; int ID_SOCIETE = int.Parse(Societe); string SOCIETE = BD.DECLARATIONS.Where(Soc => Soc.ID == ID_SOCIETE).FirstOrDefault().SOCIETE; ViewBag.SOCIETE_NAME = SOCIETE; return(View(Employee)); }
public IHttpActionResult PutEMPLOYEES(int id, EMPLOYEES eMPLOYEES) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eMPLOYEES.MANAGER_ID) { return(BadRequest()); } db.Entry(eMPLOYEES).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EMPLOYEESExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(long id) { EMPLOYEES eMPLOYEES = db.EMPLOYEES.Find(id); db.EMPLOYEES.Remove(eMPLOYEES); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult SendForm(string Mode, string Code) { string MATRICULE = Request.Params["MATRICULE"] != null ? Request.Params["MATRICULE"].ToString() : string.Empty; string employee = Request.Params["employee"] != null ? Request.Params["employee"].ToString() : string.Empty; string DATE = Request.Params["DATE"] != null ? Request.Params["DATE"].ToString() : string.Empty; string JOURNALE = Request.Params["JOURNALE"] != null ? Request.Params["JOURNALE"].ToString() : string.Empty; string NUM_PIECE = Request.Params["NUM_PIECE"] != null ? Request.Params["NUM_PIECE"].ToString() : string.Empty; string LIBELLE = Request.Params["LIBELLE"] != null ? Request.Params["LIBELLE"].ToString() : string.Empty; string MONTANT = Request.Params["MONTANT"] != null ? Request.Params["MONTANT"].ToString() : "0"; DateTime SelectedDate = DateTime.Parse(DATE); int ID = int.Parse(employee); EMPLOYEES SelectedEmployee = BD.EMPLOYEES.Find(ID); if (Mode == "Create") { MOUVEMENTS_COMPTABLES NewElement = new MOUVEMENTS_COMPTABLES(); NewElement.EMPLOYEE = ID; NewElement.EMPLOYEES = SelectedEmployee; NewElement.DATE = SelectedDate; NewElement.JOURNAL = JOURNALE; NewElement.NUM_PIECE = JOURNALE; NewElement.LIBELLE = LIBELLE; NewElement.MONTANT = decimal.Parse(MONTANT, NumberStyles.Any, CultureInfo.InvariantCulture); if (NewElement.MONTANT >= 0) { NewElement.ACTION = "DEBIT"; } if (NewElement.MONTANT < 0) { NewElement.ACTION = "CREDIT"; } BD.MOUVEMENTS_COMPTABLES.Add(NewElement); BD.SaveChanges(); } if (Mode == "Edit") { int SeletedPretID = int.Parse(Code); MOUVEMENTS_COMPTABLES NewElement = BD.MOUVEMENTS_COMPTABLES.Find(SeletedPretID); NewElement.EMPLOYEE = ID; NewElement.EMPLOYEES = SelectedEmployee; NewElement.DATE = SelectedDate; NewElement.JOURNAL = JOURNALE; NewElement.NUM_PIECE = JOURNALE; NewElement.LIBELLE = LIBELLE; NewElement.MONTANT = decimal.Parse(MONTANT, NumberStyles.Any, CultureInfo.InvariantCulture); if (NewElement.MONTANT >= 0) { NewElement.ACTION = "DEBIT"; } if (NewElement.MONTANT < 0) { NewElement.ACTION = "CREDIT"; } BD.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult DeleteEmp(string Code, string Filter) { int ID = int.Parse(Code); EMPLOYEES Employee = BD.EMPLOYEES.Where(emp => emp.ID == ID).FirstOrDefault(); BD.EMPLOYEES.Remove(Employee); BD.SaveChanges(); return(RedirectToAction("Employee", "CNSS", new { @Code = Filter })); }
public ActionResult Edit([Bind(Include = "ID,EMP_NO,EMPLOYEE_FIRST_NAME,EMPLOYEE_FATHER_NAME,EMPLOYEE_GRAND_NAME,EMPLOYEE_FAMILY_NAME,FULL_NAME,SOLDIER_NO,IDENTITY_NO,EMP_H_DATE,GENDER,PHONE,PROV_ID,DEPT_ID,DIV_ID,SECTION_ID,EMAIL,CREATION_USER_ID,CREATION_DATE")] EMPLOYEES eMPLOYEES) { if (ModelState.IsValid) { db.Entry(eMPLOYEES).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eMPLOYEES)); }
private void InsertIntoList(Stream fStream, DataTable listTable) { try { for (int iRow = 0; iRow < listTable.Rows.Count; iRow++) { string MATRICULE = listTable.Rows[iRow][0] != null?Convert.ToString(listTable.Rows[iRow][0]) : ""; string FULLENAME = listTable.Rows[iRow][1] != null?Convert.ToString(listTable.Rows[iRow][1]) : ""; string MONTANT = listTable.Rows[iRow][2] != null?Convert.ToString(listTable.Rows[iRow][2]) : "0"; string DATE = listTable.Rows[iRow][3] != null?Convert.ToString(listTable.Rows[iRow][3]) : DateTime.Today.ToShortDateString(); string TYPE = listTable.Rows[iRow][4] != null?Convert.ToString(listTable.Rows[iRow][4]) : ""; EMPLOYEES SelectedEmploye = BD.EMPLOYEES.Where(Element => Element.NUMERO == MATRICULE).FirstOrDefault(); if (SelectedEmploye == null) { SelectedEmploye = new EMPLOYEES(); SelectedEmploye.FULLNAME = FULLENAME; SelectedEmploye.NUMERO = MATRICULE; if (BD.DECLARATIONS.FirstOrDefault() != null) { SelectedEmploye.SOCIETES = BD.DECLARATIONS.FirstOrDefault(); SelectedEmploye.SOCIETE = BD.DECLARATIONS.FirstOrDefault().ID; } BD.EMPLOYEES.Add(SelectedEmploye); BD.SaveChanges(); } DateTime dateValue; if (DateTime.TryParse(DATE, out dateValue)) { DateTime NewDate = DateTime.Parse(DATE); AVANCES nouvelleAvance = new AVANCES(); nouvelleAvance.EMPLOYEE = SelectedEmploye.ID; nouvelleAvance.EMPLOYEES = SelectedEmploye; nouvelleAvance.MONTANT = !string.IsNullOrEmpty(MONTANT) ? decimal.Parse(MONTANT) : 0; nouvelleAvance.DATE = NewDate; nouvelleAvance.MOIS = NewDate.Month; nouvelleAvance.ANNEE = NewDate.Year; nouvelleAvance.TYPE = TYPE; BD.AVANCES.Add(nouvelleAvance); BD.SaveChanges(); } } } catch (Exception) { } finally { }; }
public IHttpActionResult GetEMPLOYEES(int id) { EMPLOYEES eMPLOYEES = db.EMPLOYEES.Find(id); if (eMPLOYEES == null) { return(NotFound()); } return(Ok(eMPLOYEES)); }
public string GetEmployeeByID(int ID) { EMPLOYEES Employee = BD.EMPLOYEES.Find(ID); string Result = string.Empty; if (Employee != null) { Result = Employee.NUMERO; } return(Result); }
public ActionResult Index() { if (_employees.Count == 0) { _employees = dbOperations.GetEmployees(); } _currentEmployee = _employees.Find(e => e.AADName.ToLower() == User.Identity.Name.ToLower()); return(View(_currentEmployee)); }
public IHttpActionResult PostEMPLOYEES(EMPLOYEES eMPLOYEES) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EMPLOYEES.Add(eMPLOYEES); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = eMPLOYEES.MANAGER_ID }, eMPLOYEES)); }
private void EditEmployeeOnHRProjectEmployeeTable(EMPLOYEES entity) { try { var Query = "Update [dbo].[HrPslEmployee] " + "set [EmployeeCode] = " + entity.EMP_CODE + " , [EmployeeFirstName] = N'" + entity.EMP_AR_NAME + "'" + " , [EmployeeFirstNameEN] = N'" + entity.EMP_EN_NAME + "' Where [GoldEmployeeId] = " + entity.EMP_ID; employeeRepo.ExecuteSqlCommand(Query); } catch (Exception) { } }
public RESPONSE_MODEL UpdateUserProfile(EMPLOYEES source) { try { ctx.EMPLOYEES.Add(source); ctx.SaveChanges(); } catch (Exception ex) { resp = ErrorCollection(ex); } return(resp); }
public int InsertGetID(EMPLOYEEVM entity) { if (entity.Item_Base64_Photo != null) { string base64 = entity.Item_Base64_Photo; entity.Item_Base64_Photo = String.Format(base64); base64 = base64.Remove(0, base64.IndexOf("base64,") + 7); entity.EMP_PHOTO = Convert.FromBase64String(base64); } EMPLOYEES emp = new EMPLOYEES { ACC_ID = entity.ACC_ID, AddedBy = entity.AddedBy, AddedOn = entity.AddedOn, COM_BRN_ID = entity.COM_BRN_ID, DEPT_ID = entity.DEPT_ID, Disable = entity.Disable, EMP_ADDR_REMARKS = entity.EMP_ADDR_REMARKS, EMP_AR_NAME = entity.EMP_AR_NAME, EMP_BARCODE = entity.EMP_BARCODE, EMP_BARCODE_IMAGE = entity.EMP_BARCODE_IMAGE, EMP_CODE = entity.EMP_CODE, EMP_EN_NAME = entity.EMP_EN_NAME, EMP_ID = entity.EMP_ID, EMP_NATIONAL_ID = entity.EMP_NATIONAL_ID, EMP_PHOTO = entity.EMP_PHOTO, EMP_REMARKS = entity.EMP_REMARKS, EMP_STATE = entity.EMP_STATE, EMP_TYPE_ID = entity.EMP_TYPE_ID, GOV_ID = entity.GOV_ID, NATIONALITY_ID = entity.NATIONALITY_ID, NATION_ID = entity.NATION_ID, TOWN_ID = entity.TOWN_ID, UpdatedBy = entity.UpdatedBy, updatedOn = entity.updatedOn, VILLAGE_ID = entity.VILLAGE_ID, Visa_Number = entity.Visa_Number, Pass_Number = entity.Pass_Number, Visa_ExpDateM = entity.Visa_ExpDateM, Visa_ExpDateH = entity.Visa_ExpDateH, Pass_ExpDate = entity.Pass_ExpDate }; employeeRepo.Add(emp); //todo:Remove this after full integration with HR project AddEmployeeOnHRProjectEmployeeTable(emp); return(emp.EMP_ID); }
// GET: EMPLOYEES/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EMPLOYEES eMPLOYEES = db.EMPLOYEES.Find(id); if (eMPLOYEES == null) { return(HttpNotFound()); } return(View(eMPLOYEES)); }
public IHttpActionResult DeleteEMPLOYEES(int id) { EMPLOYEES eMPLOYEES = db.EMPLOYEES.Find(id); if (eMPLOYEES == null) { return(NotFound()); } db.EMPLOYEES.Remove(eMPLOYEES); db.SaveChanges(); return(Ok(eMPLOYEES)); }
//todo:Remove this functions after full integration with HR project //**************************************************************// private void AddEmployeeOnHRProjectEmployeeTable(EMPLOYEES entity) { try { var Query = "CREATE TABLE #temp (id [int]) " + "Insert [dbo].[HrPslEmployee] ([GoldEmployeeId],[EmployeeCode],[EmployeeFirstName],[EmployeeFirstNameEN],[EmployeeLastName],[EmployeeLastNameEN]) " + "OUTPUT INSERTED.HrPslEmployeeID into #temp " + "values (" + entity.EMP_ID + "," + entity.EMP_CODE + ",N'" + entity.EMP_AR_NAME + "'," + "N'" + entity.EMP_EN_NAME + "','','') " + "update EMPLOYEES set HrPslEmployeeId = (select top 1 id from #temp) where EMP_ID = " + entity.EMP_ID + " " + "drop table #temp"; employeeRepo.ExecuteSqlCommand(Query); } catch (Exception) { } }
public Task <int> InsertGetIDAsync(EMPLOYEEVM entity) { return(Task.Run <int>(() => { EMPLOYEES emp = new EMPLOYEES { ACC_ID = entity.ACC_ID, AddedBy = entity.AddedBy, AddedOn = entity.AddedOn, COM_BRN_ID = entity.COM_BRN_ID, DEPT_ID = entity.DEPT_ID, Disable = entity.Disable, EMP_ADDR_REMARKS = entity.EMP_ADDR_REMARKS, EMP_AR_NAME = entity.EMP_AR_NAME, EMP_BARCODE = entity.EMP_BARCODE, EMP_BARCODE_IMAGE = entity.EMP_BARCODE_IMAGE, EMP_CODE = entity.EMP_CODE, EMP_EN_NAME = entity.EMP_EN_NAME, EMP_ID = entity.EMP_ID, EMP_NATIONAL_ID = entity.EMP_NATIONAL_ID, EMP_PHOTO = entity.EMP_PHOTO, EMP_REMARKS = entity.EMP_REMARKS, EMP_STATE = entity.EMP_STATE, EMP_TYPE_ID = entity.EMP_TYPE_ID, GOV_ID = entity.GOV_ID, NATIONALITY_ID = entity.NATIONALITY_ID, NATION_ID = entity.NATION_ID, TOWN_ID = entity.TOWN_ID, UpdatedBy = entity.UpdatedBy, updatedOn = entity.updatedOn, VILLAGE_ID = entity.VILLAGE_ID, Visa_Number = entity.Visa_Number, Pass_Number = entity.Pass_Number, Visa_ExpDateM = entity.Visa_ExpDateM, Visa_ExpDateH = entity.Visa_ExpDateH, Pass_ExpDate = entity.Pass_ExpDate }; employeeRepo.Add(emp); //todo:Remove this after full integration with HR project AddEmployeeOnHRProjectEmployeeTable(emp); return emp.EMP_ID; })); }
public decimal GetCredit(EMPLOYEES Employee, string Start, string End) { decimal Result = 0; List <MOUVEMENTS_COMPTABLES> Liste = BD.MOUVEMENTS_COMPTABLES.Where(Elment => Elment.EMPLOYEES.ID == Employee.ID).ToList(); if (!string.IsNullOrEmpty(Start)) { DateTime StartDate = DateTime.Parse(Start); Liste = Liste.Where(Element => Element.DATE_AFFECATION >= StartDate).ToList(); } if (!string.IsNullOrEmpty(End)) { DateTime EndDate = DateTime.Parse(End); Liste = Liste.Where(Element => Element.DATE_AFFECATION <= EndDate).ToList(); } foreach (MOUVEMENTS_COMPTABLES Element in Liste) { Result += Element.MONTANT < 0 ? Element.MONTANT : 0; } return(Result); }
public JsonResult SaveEmployee(EMPLOYEES employee) { var result = new JsonResult(); var validationFailures = new List <ValidationFailures>(); validationFailures = validateSave(employee).ToList(); if (validationFailures.Any()) { result = Json(new { failures = validationFailures[0].Message }); return(result); } else { employee.CreatedWhen = DateTime.Now.Date; db.EMPLOYEES.Add(employee); db.SaveChanges(); result = Json(new { success = true }); } return(result); }
public decimal GetReste(EMPLOYEES Employee, string Start, string End) { decimal Result = 0; List <PRETS> Liste = BD.PRETS.Where(Elment => Elment.EMPLOYEES.ID == Employee.ID).ToList(); if (!string.IsNullOrEmpty(Start)) { DateTime StartDate = DateTime.Parse(Start); Liste = Liste.Where(Element => Element.DATE >= StartDate).ToList(); } if (!string.IsNullOrEmpty(End)) { DateTime EndDate = DateTime.Parse(End); Liste = Liste.Where(Element => Element.DATE <= EndDate).ToList(); } foreach (PRETS Element in Liste) { Result += Element.RESTE; } return(Result); }
public ActionResult SendForm(string Mode, string Code) { string MATRICULE = Request.Params["MATRICULE"] != null ? Request.Params["MATRICULE"].ToString() : string.Empty; string employee = Request.Params["employee"] != null ? Request.Params["employee"].ToString() : string.Empty; string MONTANT = Request.Params["MONTANT"] != null ? Request.Params["MONTANT"].ToString() : "0"; string DATE = Request.Params["DATE"] != null ? Request.Params["DATE"].ToString() : string.Empty; string TYPE = Request.Params["TYPE"] != null ? Request.Params["TYPE"].ToString() : string.Empty; DateTime SelectedDate = DateTime.Parse(DATE); int ID = int.Parse(employee); EMPLOYEES SelectedEmployee = BD.EMPLOYEES.Find(ID); if (Mode == "Create") { AVANCES NouvelleAvance = new AVANCES(); NouvelleAvance.DATE = SelectedDate; NouvelleAvance.ANNEE = SelectedDate.Year; NouvelleAvance.MOIS = SelectedDate.Month; NouvelleAvance.MONTANT = decimal.Parse(MONTANT); NouvelleAvance.EMPLOYEES = SelectedEmployee; NouvelleAvance.EMPLOYEE = ID; NouvelleAvance.TYPE = TYPE; BD.AVANCES.Add(NouvelleAvance); BD.SaveChanges(); } if (Mode == "Edit") { int SeletedAvanceID = int.Parse(Code); AVANCES SelectedAvance = BD.AVANCES.Find(SeletedAvanceID); SelectedAvance.DATE = SelectedDate; SelectedAvance.ANNEE = SelectedDate.Year; SelectedAvance.MOIS = SelectedDate.Month; SelectedAvance.MONTANT = decimal.Parse(MONTANT); SelectedAvance.EMPLOYEES = SelectedEmployee; SelectedAvance.EMPLOYEE = ID; SelectedAvance.TYPE = TYPE; BD.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult SendForm(string Mode, string Code) { string CODE_PRET = Request.Params["CODE_PRET"] != null ? Request.Params["CODE_PRET"].ToString() : string.Empty; string MATRICULE = Request.Params["MATRICULE"] != null ? Request.Params["MATRICULE"].ToString() : string.Empty; string employee = Request.Params["employee"] != null ? Request.Params["employee"].ToString() : "0"; string MONTANT = Request.Params["MONTANT"] != null ? Request.Params["MONTANT"].ToString() : string.Empty; string DATE = Request.Params["DATE"] != null ? Request.Params["DATE"].ToString() : string.Empty; //string DATE_ECHEANCE = Request.Params["DATE_ECHEANCE"] != null ? Request.Params["DATE_ECHEANCE"].ToString() : string.Empty; string NBR_MOIS = Request.Params["NBR_MOIS"] != null ? Request.Params["NBR_MOIS"].ToString() : string.Empty; string TYPE = Request.Params["TYPE"] != null ? Request.Params["TYPE"].ToString() : string.Empty; DateTime SelectedDate = DateTime.Parse(DATE); //DateTime SelectedEcheDate = DateTime.Parse(DATE_ECHEANCE); int ID = int.Parse(employee); EMPLOYEES SelectedEmployee = BD.EMPLOYEES.Find(ID); if (Mode == "Create") { PRETS Unpret = new PRETS(); Unpret.CODE = CODE_PRET; Unpret.EMPLOYEE = ID; Unpret.EMPLOYEES = SelectedEmployee; Unpret.MONTANT = decimal.Parse(MONTANT); Unpret.RECU = 0; Unpret.RESTE = decimal.Parse(MONTANT); Unpret.DATE = SelectedDate; //Unpret.DATE_ECHEANCE = SelectedEcheDate; Unpret.NBR_MOIS = int.Parse(NBR_MOIS); Unpret.TYPE = TYPE; Unpret.STATUT = "NON CLOTURE"; BD.PRETS.Add(Unpret); BD.SaveChanges(); decimal MontantApayer = decimal.Parse(MONTANT); for (int i = 0; i < int.Parse(NBR_MOIS); i++) { TRANCHES_PRETS UneTranche = new TRANCHES_PRETS(); UneTranche.PRET = Unpret.ID; UneTranche.PRETS = Unpret; UneTranche.MONTANT = MontantApayer / int.Parse(NBR_MOIS); UneTranche.DATE = Unpret.DATE.AddMonths(i); UneTranche.STATUT = "1"; BD.TRANCHES_PRETS.Add(UneTranche); BD.SaveChanges(); } } if (Mode == "Edit") { int SeletedPretID = int.Parse(Code); PRETS Unpret = BD.PRETS.Find(SeletedPretID); Unpret.CODE = CODE_PRET; Unpret.EMPLOYEE = ID; Unpret.EMPLOYEES = SelectedEmployee; Unpret.MONTANT = decimal.Parse(MONTANT); Unpret.RECU = 0; Unpret.RESTE = decimal.Parse(MONTANT); Unpret.DATE = SelectedDate; //Unpret.DATE_ECHEANCE = SelectedEcheDate; Unpret.NBR_MOIS = int.Parse(NBR_MOIS); Unpret.TYPE = TYPE; Unpret.STATUT = "NON CLOTURE"; BD.SaveChanges(); BD.TRANCHES_PRETS.Where(p => p.PRETS.ID == SeletedPretID).ToList().ForEach(p => BD.TRANCHES_PRETS.Remove(p)); BD.SaveChanges(); decimal MontantApayer = decimal.Parse(MONTANT); for (int i = 0; i < int.Parse(NBR_MOIS); i++) { TRANCHES_PRETS UneTranche = new TRANCHES_PRETS(); UneTranche.PRET = Unpret.ID; UneTranche.PRETS = Unpret; UneTranche.MONTANT = MontantApayer / int.Parse(NBR_MOIS); UneTranche.DATE = Unpret.DATE.AddMonths(i); UneTranche.STATUT = "1"; BD.TRANCHES_PRETS.Add(UneTranche); BD.SaveChanges(); } } return(RedirectToAction("Index")); }
private void InsertIntoList(Stream fStream, DataTable listTable) { try { for (int iRow = 0; iRow < listTable.Rows.Count; iRow++) { string NUMERO_PRET = listTable.Rows[iRow][0] != null?Convert.ToString(listTable.Rows[iRow][0]) : ""; string MATRICULE = listTable.Rows[iRow][1] != null?Convert.ToString(listTable.Rows[iRow][1]) : ""; string NOM = listTable.Rows[iRow][2] != null?Convert.ToString(listTable.Rows[iRow][2]) : ""; string PRENOM = listTable.Rows[iRow][3] != null?Convert.ToString(listTable.Rows[iRow][3]) : ""; string MONTANT = listTable.Rows[iRow][4] != null?Convert.ToString(listTable.Rows[iRow][4]) : "0"; string DATE = listTable.Rows[iRow][5] != null?Convert.ToString(listTable.Rows[iRow][5]) : DateTime.Today.ToShortDateString(); string NBR_ECHAEANCE = listTable.Rows[iRow][6] != null?Convert.ToString(listTable.Rows[iRow][6]) : "1"; string NUMERO_ECHEANCE = listTable.Rows[iRow][7] != null?Convert.ToString(listTable.Rows[iRow][7]) : "1"; string MONTANT_ECHEANCE = listTable.Rows[iRow][8] != null?Convert.ToString(listTable.Rows[iRow][8]) : "0"; string DATE_ECHEANCE = listTable.Rows[iRow][9] != null?Convert.ToString(listTable.Rows[iRow][9]) : DateTime.Today.ToShortDateString(); string STAUT_ECHEANCE = listTable.Rows[iRow][10] != null?Convert.ToString(listTable.Rows[iRow][10]) : ""; string TYPE_PRET = listTable.Rows[iRow][11] != null?Convert.ToString(listTable.Rows[iRow][11]) : "01"; TRANCHES_PRETS SelectedTranche = BD.TRANCHES_PRETS.Where(Element => Element.NUMERO == NUMERO_ECHEANCE && Element.PRETS.CODE == NUMERO_PRET).FirstOrDefault(); PRETS SelectedPret = BD.PRETS.Where(Element => Element.CODE == NUMERO_PRET).FirstOrDefault(); if (SelectedTranche == null) { if (SelectedPret == null) { EMPLOYEES SelectedEmploye = BD.EMPLOYEES.Where(Element => Element.NUMERO == MATRICULE).FirstOrDefault(); if (SelectedEmploye == null) { SelectedEmploye = new EMPLOYEES(); SelectedEmploye.FULLNAME = PRENOM + " " + NOM; SelectedEmploye.NUMERO = MATRICULE; if (BD.DECLARATIONS.FirstOrDefault() != null) { SelectedEmploye.SOCIETES = BD.DECLARATIONS.FirstOrDefault(); SelectedEmploye.SOCIETE = BD.DECLARATIONS.FirstOrDefault().ID; } BD.EMPLOYEES.Add(SelectedEmploye); BD.SaveChanges(); } DateTime dateValue; if (DateTime.TryParse(DATE, out dateValue)) { decimal montant = !string.IsNullOrEmpty(MONTANT) ? decimal.Parse(MONTANT) : 0; DateTime NewDate = DateTime.Parse(DATE); SelectedPret = new PRETS(); SelectedPret.CODE = NUMERO_PRET; SelectedPret.EMPLOYEE = SelectedEmploye.ID; SelectedPret.EMPLOYEES = SelectedEmploye; SelectedPret.MONTANT = montant; SelectedPret.DATE = NewDate; SelectedPret.DATE_ECHEANCE = NewDate; SelectedPret.NBR_MOIS = !string.IsNullOrEmpty(NBR_ECHAEANCE) ? int.Parse(NBR_ECHAEANCE) : 1; SelectedPret.RECU = 0; SelectedPret.RESTE = montant; SelectedPret.TYPE = TYPE_PRET; SelectedPret.STATUT = "NON CLOTURE"; BD.PRETS.Add(SelectedPret); BD.SaveChanges(); } } SelectedTranche = new TRANCHES_PRETS(); decimal montantTranche = !string.IsNullOrEmpty(MONTANT_ECHEANCE) ? decimal.Parse(MONTANT_ECHEANCE) : 0; SelectedTranche.MONTANT = montantTranche; SelectedTranche.NUMERO = NUMERO_ECHEANCE; SelectedTranche.DATE = DateTime.Parse(DATE_ECHEANCE); SelectedTranche.STATUT = STAUT_ECHEANCE; SelectedTranche.PRET = SelectedPret.ID; SelectedTranche.PRETS = SelectedPret; BD.TRANCHES_PRETS.Add(SelectedTranche); BD.SaveChanges(); } else { decimal montantTranche = !string.IsNullOrEmpty(MONTANT_ECHEANCE) ? decimal.Parse(MONTANT_ECHEANCE) : 0; SelectedTranche.MONTANT = montantTranche; SelectedTranche.NUMERO = NUMERO_ECHEANCE; SelectedTranche.DATE = DateTime.Parse(DATE_ECHEANCE); SelectedTranche.STATUT = STAUT_ECHEANCE; BD.SaveChanges(); } if (SelectedTranche.STATUT == "2") { SelectedPret.RECU += SelectedTranche.MONTANT; SelectedPret.RESTE -= SelectedTranche.MONTANT; if (SelectedPret.RESTE <= 0) { SelectedPret.STATUT = "CLOTURE"; } BD.SaveChanges(); } } } catch (Exception) { } finally { }; }
public static IList <ValidationFailures> validateSave(EMPLOYEES employee) { var failures = new List <ValidationFailures>(); if (employee == null) { failures.Add(new ValidationFailures { Message = "Por favor Preencha todos os Campos." }); } else { if (string.IsNullOrEmpty(employee.Name)) { failures.Add(new ValidationFailures { Message = "Por favor informe o nome do funcionário." }); } if (string.IsNullOrEmpty(employee.Cpf)) { failures.Add(new ValidationFailures { Message = "Por favor informe o Cpf do funcionário." }); } if (!string.IsNullOrEmpty(employee.Cpf)) { var isValid = IsCpf(employee.Cpf); if (!isValid) { failures.Add(new ValidationFailures { Message = "Por favor digite um Cpf Válido." }); } } if (employee.CompanyId <= 0) { failures.Add(new ValidationFailures { Message = "Por favor Selecione uma Empresa." }); } if (employee.FunctionId <= 0) { failures.Add(new ValidationFailures { Message = "Por Favor Selecione uma Função para o funcionário." }); } if (employee.Phone <= 0) { failures.Add(new ValidationFailures { Message = "Por favor informe um número de telefone para contato." }); } } return(failures); }
public ActionResult SendFormAttestation(string Mode, string Code) { string REFERENCE = Request.Params["REFERENCE"] != null ? Request.Params["REFERENCE"].ToString() : string.Empty; string MODELE = Request.Params["MODELE"] != null ? Request.Params["MODELE"].ToString() : string.Empty; string employee = Request.Params["employee"] != null ? Request.Params["employee"].ToString() : string.Empty; string LOCALITE = Request.Params["LOCALITE"] != null ? Request.Params["LOCALITE"].ToString() : string.Empty; string DATE = Request.Params["DATE"] != null ? Request.Params["DATE"].ToString() : string.Empty; string SIGNE_PAR = Request.Params["SIGNE_PAR"] != null ? Request.Params["SIGNE_PAR"].ToString() : string.Empty; string DECHARGE = Request.Params["DECHARGE"] != null ? "true" : "false"; string COMMENTAIRE = Request.Params["COMMENTAIRE"] != null ? Request.Params["COMMENTAIRE"].ToString() : ""; DateTime SelectedDate = DateTime.Parse(DATE); int ID = int.Parse(employee); EMPLOYEES SelectedEmployee = BD.EMPLOYEES.Find(ID); int SelectedModel = int.Parse(MODELE); MODELES_ATTESTATIONS Model = BD.MODELES_ATTESTATIONS.Find(SelectedModel); if (Mode == "Create") { int Max = 1; List <ATTESTATIONS> liste = BD.ATTESTATIONS.Where(Elt => Elt.DATE.Year == DateTime.Today.Year).ToList(); if (liste.Count > 0) { Max = liste.Select(Elt => Elt.NUMERO).Max(); Max++; } ATTESTATIONS NewElement = new ATTESTATIONS(); NewElement.EMPLOYE = ID; NewElement.EMPLOYEES = SelectedEmployee; NewElement.DATE = SelectedDate; NewElement.REFERENCE = REFERENCE; NewElement.NUMERO = Max; NewElement.MODELE = SelectedModel; NewElement.MODELES_ATTESTATIONS = Model; NewElement.LOCALITE = LOCALITE; NewElement.COMMENTAIRE = COMMENTAIRE != "undefined" ? COMMENTAIRE : string.Empty; NewElement.SIGNE_PAR = SIGNE_PAR; NewElement.DECHARGE = Boolean.Parse(DECHARGE); BD.ATTESTATIONS.Add(NewElement); BD.SaveChanges(); } if (Mode == "Edit") { int SeletedPretID = int.Parse(Code); ATTESTATIONS NewElement = BD.ATTESTATIONS.Find(SeletedPretID); NewElement.EMPLOYE = ID; NewElement.EMPLOYEES = SelectedEmployee; NewElement.DATE = SelectedDate; //NewElement.REFERENCE = REFERENCE; //NewElement.NUMERO = Max; NewElement.MODELE = SelectedModel; NewElement.MODELES_ATTESTATIONS = Model; NewElement.LOCALITE = LOCALITE; NewElement.COMMENTAIRE = COMMENTAIRE != "undefined" ? COMMENTAIRE : string.Empty; NewElement.SIGNE_PAR = SIGNE_PAR; NewElement.DECHARGE = Boolean.Parse(DECHARGE); BD.SaveChanges(); } return(RedirectToAction("Index")); }
public string GetDescriptionByEmployee(int id) { string Result = string.Empty; ATTESTATIONS attestation = BD.ATTESTATIONS.Find(id); EMPLOYEES employee = attestation.EMPLOYEES; MODELES_ATTESTATIONS model = attestation.MODELES_ATTESTATIONS; List <CHAMPS_MODELES> liste = BD.CHAMPS_MODELES.Where(Element => Element.MODELES_ATTESTATIONS.ID == model.ID).OrderBy(Element => Element.ORDRE).ToList(); foreach (CHAMPS_MODELES Element in liste) { if (Element.TYPE == "TEXT") { if (Element.VALEUR.Trim() == string.Empty) { Result += Environment.NewLine; Result += Environment.NewLine; } Result += Element.VALEUR + " "; } if (Element.TYPE == "TABLE") { if (Element.VALEUR == "CIN") { Result += employee.CIN + " "; } if (Element.VALEUR == "FULLNAME") { Result += employee.FULLNAME + " "; } if (Element.VALEUR == "NUM_ASS_SOC") { Result += employee.NUM_ASS_SOC + " "; } if (Element.VALEUR == "QUALIFICATION") { Result += employee.QUALIFICATION + " "; } if (Element.VALEUR == "NUMERO") { Result += employee.NUMERO + " "; } if (Element.VALEUR == "ADRESSE") { Result += employee.ADRESSE + " "; } if (Element.VALEUR == "CIVILITE") { Result += employee.CIVILITE + " "; } if (Element.VALEUR == "SALAIRE") { Result += ((decimal)employee.SALAIRE) * 13 + " "; } if (Element.VALEUR == "DEMARRAGE") { Result += employee.DEMARRAGE.Value.ToShortDateString() + " "; } } } return(Result); }