private void UpdateDatabase() { int companyId = Int32.Parse(hdfCompanyId.Value); DB.Open(); DB.BeginTransaction(); try { SizeInformation sizeInformation = new SizeInformation(sizeInformationTDS); sizeInformation.Save(companyId); DB.CommitTransaction(); // Store datasets sizeInformationTDS.AcceptChanges(); Session["sizeInformationTDS"] = sizeInformationTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
protected void grdSize_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("sizeDataEdit"); if (Page.IsValid) { string originalSize_ = e.Keys["Size_"].ToString(); int companyId = (int)e.Keys["COMPANY_ID"]; string newSize_ = ((TextBox)grdSize.Rows[e.RowIndex].Cells[2].FindControl("tbxSizeEdit")).Text.Trim(); if (originalSize_ != newSize_) { // Update data SizeInformation model = new SizeInformation(sizeInformationTDS); model.Update(originalSize_, newSize_, companyId); } // Store dataset Session.Remove("sizeInformationNewDummy"); Session["sizeInformationTDS"] = sizeInformationTDS; Session["sizeInformation"] = sizeInformationTDS.SizeInformation; } else { e.Cancel = true; } }
private void GrdSizeAdd() { if (ValidateSizeFooter()) { Page.Validate("sizeDataNew"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); string size_ = ((TextBox)grdSize.FooterRow.FindControl("tbxSizeNew")).Text.Trim(); bool newInDatabase = false; SizeInformation model = new SizeInformation(sizeInformationTDS); model.Insert(size_, companyId, false, newInDatabase); Session.Remove("sizeInformationNewDummy"); Session["sizeInformationTDS"] = sizeInformationTDS; Session["sizeInformation"] = sizeInformationTDS.SizeInformation; grdSize.DataBind(); grdSize.PageIndex = grdSize.PageCount - 1; } } }
protected void grdSize_RowDeleting(object sender, GridViewDeleteEventArgs e) { Page.Validate("sizeData"); if (Page.IsValid) { string size_ = e.Keys["Size_"].ToString(); int companyId = (int)e.Keys["COMPANY_ID"]; SizeInformation model = new SizeInformation(sizeInformationTDS); // Delete size model.Delete(size_, companyId); // Store dataset Session.Remove("sizeInformationNewDummy"); Session["sizeInformationTDS"] = sizeInformationTDS; Session["sizeInformation"] = sizeInformationTDS.SizeInformation; } else { e.Cancel = true; } }