public void Delete(ProductCategories delObj) { using (var session = GetSession()) { using (var trans = session.BeginTransaction()) { session.Delete(delObj); trans.Commit(); } } }
public void Save(ProductCategories saveObj) { using (var session = GetSession()) { using (var trans = session.BeginTransaction()) { session.FlushMode = FlushMode.Commit; session.SaveOrUpdate(saveObj); trans.Commit(); session.Flush(); //} } } }
private void fillValues() { prodCat = pCatRepo.GetById(strKey); Session["prodCat"] = prodCat; if (prodCat != null) { txtCodeLongDesc.Text = prodCat.ProductCatDesc; txtCodeShortDesc.Text = prodCat.ProductCatShortDesc; cmbModule.SelectedValue = prodCat.ProductCatModule; cmbCatCode.SelectedValue = prodCat.ProductCatCode; updateFlag = true; Session["updateFlag"] = updateFlag; } }
protected void butSave_Click(object sender, EventArgs e) { //this routine will persist only one object. //1. The indlifecodes object updateFlag = (bool)Session["updateFlag"]; if (!updateFlag) //if new record { //create a new instance of the indlifecode object prodCat = new CustodianLife.Model.ProductCategories(); lblError.Visible = false; prodCat.ProductCatModule = cmbModule.SelectedValue; prodCat.ProductCatCode = cmbCatCode.SelectedValue; prodCat.ProductCatDesc = txtCodeLongDesc.Text; prodCat.ProductCatShortDesc = txtCodeShortDesc.Text; pCatRepo.Save(prodCat); Session["prodCat"] = prodCat; } else { prodCat = (CustodianLife.Model.ProductCategories)Session["prodCat"]; prodCat.ProductCatModule = cmbModule.SelectedValue; prodCat.ProductCatCode = cmbCatCode.SelectedValue; prodCat.ProductCatDesc = txtCodeLongDesc.Text; prodCat.ProductCatShortDesc = txtCodeShortDesc.Text; pCatRepo.Save(prodCat); } initializeFields(); }