protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SetTransactionOptions(Options, true, false, false, false, false, false, false); SetPageDescription(Resources.MainMenu.IM_03_01); currentOption = Options.SelectedValue; string pu = Request.QueryString["PU"]; string fefid = Request.QueryString["FID"]; string stateid = Request.QueryString["ST"]; if (fefid != null) { CompanyFormID.Value = fefid; currentOption = "UPD"; OptionsPanel.Visible = false; SearchPanel.Visible = false; DetailPanel.Visible = true; InputPanel.Visible = true; ConfirmButtonPanel.Visible = true; FormPanel.Visible = true; FormPanel.Enabled = true; BindCountries(ddlCountry); FinancialExportForm entity = CxFinancialExportForm.GetFormById(int.Parse(fefid)); FormMessageLiteral.Text = GetPeriodMessage(Resources.Resource.lForm2Message, entity.PeriodNumber, entity.Form.Periodicity.Code, entity.FormDate); if (stateid == "3") { DetailPanel.Enabled = false; InputPanel.Visible = false; ApprovePanel.Visible = true; ConfirmButtonPanel.Visible = false; FormGridView.Columns[0].Visible = false; FormMessageLiteral.Text = ""; } ProductionUnitLiteral.Text = pu; FillDateLiteral.Text = DateTime.Now.ToShortDateString(); ShowCurrentForm(int.Parse(fefid)); } } else { currentOption = Options.SelectedValue; User user = WebSecurity.GetUserInfo(Page.User.Identity.Name); int? companyId = user.CompanyID; if (companyId != null && companyId != 0) { ddlCompany.SelectedValue = companyId.ToString(); ddlCompany.Enabled = false; } } }
private void CreateRecord(int formId, int productionUnitId) { HiddenField currentCountry = null; Label currentAmount = null; FinancialExportFormCountry countryExport = null; if (FormGridView.Rows.Count == 0) { throw new Exception(Resources.Resource.mFinancialExportMandatory); } using (var db = new Models.SmizeeContext()) { FinancialExportForm entity = new FinancialExportForm(); entity.FormID = formId; entity.StateID = 1; entity.SubmitDate = DateTime.Now; //entity.ApprovalDate = DateTime.Parse("01/01/2000 00:00:00"); entity.SubmitUserName = User.Identity.Name; db.FinancialExportForms.Add(entity); db.SaveChanges(); foreach (GridViewRow currentExport in FormGridView.Rows) { currentCountry = currentExport.FindControl("CountryIdHidden") as HiddenField; currentAmount = currentExport.FindControl("ExportAmount") as Label; countryExport = new FinancialExportFormCountry(); countryExport.CountryID = int.Parse(currentCountry.Value); countryExport.ExportAmount = GetDecimalValue(currentAmount.Text); countryExport.FinancialExportFormID = entity.FinancialExportFormID; db.FinancialExportFormCountries.Add(countryExport); } db.SaveChanges(); } BackPanel.Visible = true; ConfirmButtonPanel.Visible = false; DetailPanel.Visible = false; FormPanel.Visible = false; ShowInfo(MessagePanel, Resources.Resource.mCreateOK); }