/// <summary> /// Function to save the items to database /// </summary> public void SaveFunction() { try { decimal decIdentity = 0; FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); FinancialYearSP spFinancialYear = new FinancialYearSP(); CompanySP spCompany = new CompanySP(); infoFinancialYear.FromDate = Convert.ToDateTime(txtFromDate.Text); infoFinancialYear.ToDate = Convert.ToDateTime(txtToDate.Text); infoFinancialYear.ExtraDate = System.DateTime.Now; infoFinancialYear.Extra1 = string.Empty; infoFinancialYear.Extra2 = string.Empty; decIdentity = spFinancialYear.FinancialYearAddWithReturnIdentity(infoFinancialYear); infoFinancialYear = spFinancialYear.FinancialYearView(decIdentity); PublicVariables._decCurrentFinancialYearId = infoFinancialYear.FinancialYearId; PublicVariables._dtFromDate = infoFinancialYear.FromDate; PublicVariables._dtToDate = infoFinancialYear.ToDate; PublicVariables._dtCurrentDate = infoFinancialYear.FromDate; spCompany.CompanyCurrentDateEdit(PublicVariables._dtCurrentDate); formMDI.MDIObj.ShowCurrentDate(); isSave = true; this.Close(); } catch (Exception ex) { formMDI.infoError.ErrorString = "NFY 2 : " + ex.Message; } }
/// <summary> /// Changing company's financial year /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSelect_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are you sure you want to change the financial year?", "Oneaccount", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); FinancialYearSP spFinancialYear = new FinancialYearSP(); decimal decFinacialId = Convert.ToDecimal(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtfinancialYearId"].Value); DateTime dtmFromDate = Convert.ToDateTime(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtFromDate"].Value); DateTime dtmToDate = Convert.ToDateTime(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtToDate"].Value); PublicVariables._decCurrentFinancialYearId = decFinacialId; PublicVariables._dtFromDate = dtmFromDate; PublicVariables._dtToDate = dtmToDate; DateTime dtGetCurrentdate = DateTime.Now; CompanySP spCompany = new CompanySP(); spCompany.CompanyCurrentDateEdit(dtmFromDate); if (dtGetCurrentdate < dtmFromDate) { PublicVariables._dtCurrentDate = dtmFromDate; spCompany.CompanyCurrentDateEdit(dtmFromDate); formMDI.MDIObj.ShowCurrentDate(); } else { PublicVariables._dtCurrentDate = dtGetCurrentdate; spCompany.CompanyCurrentDateEdit(dtmFromDate); formMDI.MDIObj.ShowCurrentDate(); } CompanyInfo infoCompany = new CompanyInfo(); infoCompany = spCompany.CompanyView(1); formMDI.MDIObj.Text = "Oneaccount " + infoCompany.CompanyName + " [ " + PublicVariables._dtFromDate.ToString("dd-MMM-yyyy") + " To " + PublicVariables._dtToDate.ToString("dd-MMM-yyyy") + " ]"; this.Close(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "CHGFINYR:5" + ex.Message; } }
/// <summary> /// Save button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (txtCompanyCurrentdate.Text == string.Empty) { Messages.InformationMessage("Select a date in between financial year"); txtCompanyCurrentdate.Focus(); } else { PublicVariables._dtCurrentDate = Convert.ToDateTime(txtCompanyCurrentdate.Text); CompanySP spCompany = new CompanySP(); spCompany.CompanyCurrentDateEdit(Convert.ToDateTime(txtCompanyCurrentdate.Text)); if (frmCompanyCreationObj != null) { if ((MessageBox.Show("Saved successfully...Do you want to save settings now? ", "Oneaccount", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) == DialogResult.Yes) { frmSettings frmSettingsObj = new frmSettings(); frmSettingsObj.MdiParent = formMDI.MDIObj; frmSettingsObj.CallFromChangeCurrentDate(frmCompanyCreationObj); } } this.Close(); if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmShortExpiry", "View") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmStock", "View") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverdueSalesOrder", "View") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverduePurchaseOrder", "View") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Delete") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Update") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Save")) { ShowReminderIfAny(); } } } catch (Exception ex) { formMDI.infoError.ErrorString = "CCD 11 : " + ex.Message; } }