private void LoadGrid() { var showAll = (Conversion.TryCastString(this.Page.Request.QueryString["show"]).Equals("all")); this.BindGridView(); this.formGridView.Width = this.GetGridViewWidth(); this.formGridView.Attributes.Add("style", "white-space: nowrap;"); var userNameSessionKey = ConfigurationHelper.GetScrudParameter("UserNameSessionKey"); var officeCodeSessionKey = ConfigurationHelper.GetScrudParameter("OfficeCodeSessionKey"); this.userIdHidden.Value = CurrentSession.GetSessionValueByKey(userNameSessionKey); this.officeCodeHidden.Value = CurrentSession.GetSessionValueByKey(officeCodeSessionKey); }
// ReSharper disable once UnusedParameter.Local private void Save(bool closeForm) { string userIdSessionKey = ConfigurationHelper.GetScrudParameter("UserIdSessionKey"); if (Conversion.TryCastInteger(CurrentSession.GetSessionValueByKey(userIdSessionKey)) <= 0) { throw new InvalidOperationException("The user id session key is invalid or incorrectly configured."); } Collection <KeyValuePair <string, object> > list = this.GetFormCollection(true); string id = this.GetSelectedValue(); this.lastValueHiddenTextBox.Text = id; int userId = Conversion.TryCastInteger(this.Page.Session[userIdSessionKey]); if (string.IsNullOrWhiteSpace(id)) { try { if (this.DenyAdd) { throw new MixERPException(Titles.AccessDenied); } long lastValue = FormHelper.InsertRecord(userId, this.TableSchema, this.Table, list, this.imageColumn); if (lastValue > 0) { this.lastValueHiddenTextBox.Text = lastValue.ToString(CultureInfo.InvariantCulture); //Clear the form container. this.formContainer.Controls.Clear(); using (DataTable table = new DataTable()) { //Load the form again. this.LoadForm(this.formContainer, table, this.ResourceAssembly); } //Refresh the grid. this.BindGridView(); this.DisplaySuccess(); } } catch (MixERPException ex) { this.DisplayError(ex); } } else { try { if (this.DenyEdit) { throw new MixERPException(Titles.AccessDenied); } string[] exclusion = { "" }; if (!string.IsNullOrWhiteSpace(this.ExcludeEdit)) { exclusion = this.ExcludeEdit.Split(',').Select(x => x.Trim().ToUpperInvariant()).ToArray(); } if (FormHelper.UpdateRecord(userId, this.TableSchema, this.Table, list, this.KeyColumn, id, this.imageColumn, exclusion)) { //Clear the form container. this.formContainer.Controls.Clear(); //Load the form again. using (DataTable table = new DataTable()) { table.Locale = Thread.CurrentThread.CurrentCulture; this.LoadForm(this.formContainer, table, this.ResourceAssembly); } //Refresh the grid. this.BindGridView(); this.DisplaySuccess(); } else { this.DisplayError(new MixERPException(Titles.UnknownError)); } } catch (MixERPException ex) { this.DisplayError(ex); } } }