private void btnSave_Click(object sender, EventArgs e) { //TODO: 1. Check whether the group name exists or not //2. if exist then do not allow to save with the same group name //3. Prompt user to change the group name as it already exists if (tbxName.Text.Equals(string.Empty)) { MessageBox.Show("Group Name can not be blank!"); return; } //if (accObj.IsGroupExists(tbxGroupName.Text.Trim())) //{ // MessageBox.Show("Group Name already Exists!", "SunSpeed", MessageBoxButtons.RetryCancel); // cbxUnderGrp.Focus(); // return; //} eSunSpeedDomain.ExecutiveModel objexemod = new ExecutiveModel(); objexemod.Name = tbxName.Text; // objexe.Primary = cbxPrimarygroup.SelectedItem.ToString(); objexemod.Alias = tbxAliasname.Text; objexemod.PrintName = tbxPrintname.Text; objexemod.Address = tbxAddress.Text; objexemod.Address1 = tbxAddress1.Text; objexemod.Address2 = tbxAddress2.Text; objexemod.Address3 = tbxAddress3.Text; objexemod.TelephoneNumber = tbxTelnumber.Text; objexemod.MobileNumber = Convert.ToInt32(tbxMobileno.Text.Trim()); objexemod.HandlescallType = tbxhandlecalltype.Text; objexemod.CreatedBy = "Admin"; string message = string.Empty; bool issuccess = objexe.SaveExeGroup(objexemod); if (isSuccess) { MessageBox.Show("Saved Successfully!"); } }
//Added by Saddam/ public IHttpActionResult insertExecutive(ExecutiveModel Executive) { string status = ""; using (TransactionScope scope = new TransactionScope()) { try { ExecutiveMaster _Executive = new ExecutiveMaster(); _Executive.executiveName = Executive.executiveName; _Executive.executivecode = Executive.executivecode; _Executive.Emailid = Executive.Emailid; _Executive.DepartmentId = Executive.DepartmentId; _Executive.Mobile = Executive.Mobile; _Executive.Phoneno = Executive.Phoneno; _Executive.DepartmentId = Executive.DepartmentId; _Executive.Password = _encryptionService.EncryptText(Executive.Password, _ExecutiveService.KeyValue("encriptionkey")); _Executive.Id = Executive.Id; _Executive.EnteredBy = Executive.EnteredBy; // status = _ExecutiveService.DuplicityCheck(_Executive); status = _ExecutiveService.DuplicityExecutiveCodeCheck(_Executive); if (status == "Y") { if (Executive.Id == 0) { int ExecutiveIdId = _ExecutiveService.InsertExecutive(_Executive); if (ExecutiveIdId != 0) { ExecutiveDivisionLink Link = new ExecutiveDivisionLink(); foreach (var item in Executive.Division) { Link.executiveid = ExecutiveIdId; Link.divisionid = item; Link.EnteredBy = Executive.EnteredBy; _ExecutiveService.InsertExecutiveDivisionLinking(Link); } } if (Executive.ReportingId != 0 && ExecutiveIdId != 0 && Executive.RoleName == "executive") { ExecutiveReporting Reporting = new ExecutiveReporting(); Reporting.executiveid = ExecutiveIdId; Reporting.reportingidto = Executive.ReportingId; Reporting.EnteredBy = Executive.EnteredBy; _ExecutiveService.InsertExecutiveReporting(Reporting); } } else { ExecutiveMaster mobj_Excutive = _ExecutiveService.GetExecutiveById(_Executive.Id); //_ExecutiveService.GetDivisionById(Executive); mobj_Excutive.executiveName = Executive.executiveName; mobj_Excutive.executivecode = Executive.executivecode; mobj_Excutive.Emailid = Executive.Emailid; mobj_Excutive.Password = _encryptionService.EncryptText(Executive.Password, _ExecutiveService.KeyValue("encriptionkey")); mobj_Excutive.Mobile = Executive.Mobile; mobj_Excutive.Phoneno = Executive.Phoneno; mobj_Excutive.DepartmentId = Executive.DepartmentId; mobj_Excutive.ModifiedBy = Executive.EnteredBy; mobj_Excutive.ModifiedDate = System.DateTime.Now; _ExecutiveService.UpdateExecutive(mobj_Excutive); ExecutiveDivisionLink Link = new ExecutiveDivisionLink(); _ExecutiveService.DeactivateExecutiveDivisionLinking(Executive.Id, Executive.EnteredBy); foreach (var item in Executive.Division) { Link.executiveid = Executive.Id; Link.divisionid = item; Link.EnteredBy = Executive.EnteredBy; _ExecutiveService.InsertExecutiveDivisionLinking(Link); } if (Executive.ReportingId != 0) { _ExecutiveService.DeavtivateExecutiveReporting(Executive.Id, Executive.EnteredBy); ExecutiveReporting Reporting = new ExecutiveReporting(); Reporting.executiveid = Executive.Id; if (Executive.RoleName == "executive") { Reporting.reportingidto = Executive.ReportingId; Reporting.EnteredBy = Executive.EnteredBy; _ExecutiveService.InsertExecutiveReporting(Reporting); } else { Reporting.EnteredBy = Executive.EnteredBy; _ExecutiveService.UpdateExecutiveReporting(Reporting); } } } //--set executive repoting to or not if (Executive.ReportingId != 0) { ExecutiveMaster mobj_Excutive = _ExecutiveService.GetExecutiveById(Executive.ReportingId); mobj_Excutive.ProcessTransferTo = Executive.ProcessTransferTo; _ExecutiveService.UpdateExecutive(mobj_Excutive); } //------------------------- status = _localizationService.GetResource("Master.API.Success.Message"); scope.Complete(); } else { status = "Duplicate"; } } catch (ACSException ex) { status = ex.InnerException.Message; } catch (Exception ex) { status = ex.InnerException.Message; } } return(Json(status)); }