public bool UpdateCompanyInfo(TBL_MP_Admin_Company_Master model) { bool result = false; bool exists = false; try { TBL_MP_Admin_Company_Master dbModel = _dbContext.TBL_MP_Admin_Company_Master.FirstOrDefault(); if (dbModel == null) { dbModel = new TBL_MP_Admin_Company_Master(); } else { exists = true; } //gather into properties dbModel.CompanyCode = model.CompanyCode; dbModel.Company_name = model.Company_name; dbModel.Abbreviation = model.Abbreviation; dbModel.FK_CountryID = model.FK_CountryID; dbModel.FK_StateID = model.FK_StateID; dbModel.FK_CityID = model.FK_CityID; dbModel.FK_AreaID = model.FK_AreaID; dbModel.Email = model.Email; dbModel.Website = model.Website; dbModel.PhoneNo = model.PhoneNo; dbModel.FaxNo = model.FaxNo; dbModel.ECC_NO = model.ECC_NO; dbModel.TIN_NO = model.TIN_NO; dbModel.PAN_NO = model.PAN_NO; dbModel.GST_NO = model.IEC_CODE; dbModel.IEC_CODE = model.IEC_CODE; dbModel.ShiftTimeFrom = model.ShiftTimeFrom; dbModel.ShiftTimeTo = model.ShiftTimeTo; if (!exists) { _dbContext.TBL_MP_Admin_Company_Master.Add(dbModel); } _dbContext.SaveChanges(); result = true; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceCompanyMaster::UpdateCompanyInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public void PopulateCompanyInformation() { try { TBL_MP_Admin_Company_Master model = (new ServiceCompanyMaster()).GetCompanyInfo(); if (model != null) { txtCode.Text = model.CompanyCode; txtCompanyName.Text = model.Company_name; txtAbbrivation.Text = model.Abbreviation; txtCompanyAddress.Text = model.Address; cboCountry.SelectedItem = ((List <SelectListItem>)cboCountry.DataSource).Where(x => x.ID == model.FK_CountryID).FirstOrDefault(); cboState.SelectedItem = ((List <SelectListItem>)cboState.DataSource).Where(x => x.ID == model.FK_StateID).FirstOrDefault(); cboCity.SelectedItem = ((List <SelectListItem>)cboCity.DataSource).Where(x => x.ID == model.FK_CityID).FirstOrDefault(); cboArea.SelectedItem = ((List <SelectListItem>)cboArea.DataSource).Where(x => x.ID == model.FK_AreaID).FirstOrDefault(); txtEmailAddress.Text = model.Email; txtWebsiteAddress.Text = model.Website; txtPhoneNo.Text = model.PhoneNo; txtFaxNo.Text = model.FaxNo; txtECCNo.Text = model.ECC_NO; txtTinNo.Text = model.TIN_NO; txtPANNo.Text = model.PAN_NO; txtGSTNo.Text = model.GST_NO; txtIECCode.Text = model.IEC_CODE; if (model.ShiftTimeFrom != null) { dtShiftFromTime.Value = AppCommon.GetDateTimeFromTime(model.ShiftTimeFrom); } if (model.ShiftTimeTo != null) { dtShiftToTime.Value = AppCommon.GetDateTimeFromTime(model.ShiftTimeTo); } } else { txtCode.Text = txtCompanyName.Text = txtAbbrivation.Text = txtEmailAddress.Text = txtWebsiteAddress.Text = txtPhoneNo.Text = txtFaxNo.Text = txtECCNo.Text = txtTinNo.Text = txtPANNo.Text = txtGSTNo.Text = string.Empty; cboCountry.SelectedItem = ((List <SelectListItem>)cboCountry.DataSource).Where(x => x.ID == 0).FirstOrDefault(); cboState.SelectedItem = ((List <SelectListItem>)cboState.DataSource).Where(x => x.ID == 0).FirstOrDefault(); cboCity.SelectedItem = ((List <SelectListItem>)cboCity.DataSource).Where(x => x.ID == 0).FirstOrDefault(); cboArea.SelectedItem = ((List <SelectListItem>)cboArea.DataSource).Where(x => x.ID == 0).FirstOrDefault(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageCompanyInfo::PopulateCompanyInformation", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSaveCompanyInfo_Click(object sender, EventArgs e) { btnCancelUpdates.Visible = btnSaveCompanyInfo.Visible = false; try { if (!this.ValidateChildren()) { return; } TBL_MP_Admin_Company_Master model = (new ServiceCompanyMaster()).GetCompanyInfo(); if (model == null) { model = new TBL_MP_Admin_Company_Master(); } model.CompanyCode = txtCode.Text.Trim(); model.Company_name = txtCompanyName.Text.Trim(); model.Abbreviation = txtAbbrivation.Text.Trim(); model.FK_CountryID = ((SelectListItem)cboCountry.SelectedItem).ID; model.FK_StateID = ((SelectListItem)cboState.SelectedItem).ID; model.FK_CityID = ((SelectListItem)cboState.SelectedItem).ID; model.FK_AreaID = ((SelectListItem)cboArea.SelectedItem).ID; model.Email = txtEmailAddress.Text.Trim(); model.Website = txtWebsiteAddress.Text.Trim(); model.PhoneNo = txtPhoneNo.Text.Trim(); model.ECC_NO = txtECCNo.Text.Trim(); model.TIN_NO = txtTinNo.Text.Trim(); model.PAN_NO = txtPANNo.Text.Trim(); model.GST_NO = txtGSTNo.Text.Trim(); model.IEC_CODE = txtIECCode.Text.Trim(); model.ShiftTimeFrom = dtShiftFromTime.Value.ToString("hh:mm tt"); model.ShiftTimeTo = dtShiftToTime.Value.ToString("hh:mm tt"); bool result = (new ServiceCompanyMaster()).UpdateCompanyInfo(model); if (result) { MessageBox.Show("Successfully Updated ", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageCompanyInfo::btnSaveCompanyInfo_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TBL_MP_Admin_Company_Master GetCompanyInfo() { TBL_MP_Admin_Company_Master model = null; try { model = _dbContext.TBL_MP_Admin_Company_Master.FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceCompanyMaster::GetCompanyInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
private void PopulateOurCompanyAddress() { try { TBL_MP_Admin_Company_Master myComp = (new ServiceMASTERS()).MyCompanyInfo(); if (myComp != null) { txtMyCompanyAddress.Text = myComp.Address; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditProject::frmAddEditProject_Load", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void SetShiftStartFromAndToDatetime(ref DateTime start, ref DateTime end) { try { EXCEL_ERP_TESTEntities conn = new EXCEL_ERP_TESTEntities(); TBL_MP_Admin_Company_Master dbModel = conn.TBL_MP_Admin_Company_Master.FirstOrDefault(); if (dbModel != null) { //format 05:15 PM start = ConvertToDateTime(start.ToString("dd-MM-yyyy"), dbModel.ShiftTimeFrom); end = ConvertToDateTime(end.ToString("dd-MM-yyyy"), dbModel.ShiftTimeTo); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "AppCommon::SetShiftStartFromAndToDatetime", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PopulateProjectGeneralInfo() { this.Cursor = Cursors.WaitCursor; Application.UseWaitCursor = true; ServiceProject _service = new ServiceProject(); try { SelectListItem selItem = null; List <SelectListItem> lst = _service.GetAllProjectStatuses(); TBL_MP_PMC_ProjectMaster model = (new ServiceProject()).GetProjectDBInfoByID(this.SelectedProjectID); if (model != null) { headerGroupMain.ValuesPrimary.Heading = model.ProjectNumber; selItem = lst.Where(x => x.ID == model.FK_ProjectStatusID).FirstOrDefault(); txtStatus.Text = selItem.Description; txtProjectNo.Text = model.ProjectNumber; txtProjectName.Text = model.ProjectName; dtProjectDate.Value = (DateTime)model.ProjectDate; dtProjectStartDate.Value = (DateTime)model.StartDate; dtProjectEndDate.Value = (DateTime)model.EndDate; // txtBillingAddress.Text = Project_generalInfo.BillingClientAddressID.ToString(); // txtClientAddress.Text = Project_generalInfo.SiteClientAddressID.ToString(); ServiceProject serviceProject = new ServiceProject(); txtBillingAddress.Text = serviceProject.GetProjectBillingAddress((int)model.PK_ProjectID); txtClientAddress.Text = serviceProject.GetProjectSiteAddress((int)model.PK_ProjectID); lblCreatedDateTime.Text = model.CreatedDatetime.ToString(); lblModifiedDateTime.Text = model.ModifiedDatetime.ToString(); ServiceEmployee emp = new ServiceEmployee(); List <SelectListItem> lst1 = emp.GetAllEmployees(); selItem = lst1.Where(x => x.ID == model.CreatedBy).FirstOrDefault(); lblCreatedBy.Text = selItem.Description; List <SelectListItem> lst2 = emp.GetAllEmployees(); selItem = lst2.Where(x => x.ID == model.ModifiedBy).FirstOrDefault(); lblModifiedBy.Text = selItem.Description; TBL_MP_Admin_Company_Master myComp = (new ServiceMASTERS()).MyCompanyInfo(); if (myComp != null) { txtCompanyAddress.Text = myComp.Address; } } else { txtProjectNo.Text = txtProjectName.Text = txtStatus.Text = txtBillingAddress.Text = txtClientAddress.Text = txtCompanyAddress.Text = string.Empty; dtProjectDate.Checked = dtProjectStartDate.Checked = dtProjectEndDate.Checked = false; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ControlProjectGeneralInfo::PopulateProjectGeneralInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; Application.UseWaitCursor = false; }