public List <Models.MProducts> GetAllbyid(int id) { List <Models.MProducts> model = new List <Models.MProducts>(); var query = from o in obj.Products where (o.id) == id select o; foreach (var item in query) { Models.MProducts m = new Models.MProducts(); m.id = Convert.ToString(item.id); m.ProductCode = item.ProductCode; m.Name = item.Name; m.tag1 = item.tag2; m.tag2 = item.tag2; m.tag3 = item.tag3; m.SalePrice = item.salePrice; m.CostPrice = item.costPrice; m.Manufacturer = item.Manufacturer; m.description = item.Description; m.Vendorld = Convert.ToString(item.VendorId); m.FiscalYearld = Convert.ToString(item.FiscalYearId); m.eDate = Convert.ToString(item.eDate); model.Add(m); } return(model); }
public int Save(Models.MProducts model) { Common.Logger l = new Common.Logger(); string ClassName = "CProducts"; try { DB.Product bs = new DB.Product(); //bs.id = int.Parse(model.id); bs.ProductCode = model.ProductCode; bs.Name = model.Name; bs.tag1 = model.tag1; bs.tag2 = model.tag1; bs.tag3 = model.tag3; bs.costPrice = model.CostPrice; bs.salePrice = model.SalePrice; bs.Manufacturer = model.Manufacturer; bs.Description = model.description; bs.VendorId = int.Parse(model.Vendorld); bs.FiscalYearId = Convert.ToInt32(model.FiscalYearld); bs.eDate = DateTime.Now; bs.WareHouseId = Convert.ToInt32(model.WareHouseId); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductCode[" + model.ProductCode + "] Name[" + model.Name + "] tag1[" + model.tag1 + "] tag2[ " + model.tag2 + "] tag3 [" + model.tag3 + " ] Manufacture[ " + model.Manufacturer + " ] Description [ " + model.description + "] VendorId [ " + model.Vendorld + "] FiscalYearId [ " + model.FiscalYearld + "] eDate[ " + model.eDate + "]"); obj.Products.InsertOnSubmit(bs); obj.SubmitChanges(); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully"); return(1); } catch (Exception ex) { l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
public List <Models.MProducts> GetAll() { List <Models.MProducts> model = new List <Models.MProducts>(); var query = from o in obj.Products select o; foreach (var item in query) { Models.MProducts m = new Models.MProducts(); m.id = Convert.ToString(item.id); m.ProductCode = item.ProductCode; m.Name = item.Name; m.tag1 = item.tag2; m.tag2 = item.tag2; m.tag3 = item.tag3; m.CostPrice = item.costPrice; m.SalePrice = item.salePrice; m.Manufacturer = item.Manufacturer; m.description = item.Description; Classes.CVendor cv = new CVendor(); m.Vendorld = Convert.ToString(item.VendorId); m.VendorName = cv.GetVendorNameById(m.Vendorld); m.FiscalYearld = Convert.ToString(item.FiscalYearId); m.eDate = Convert.ToString(item.eDate); m.WareHouseId = Convert.ToString(item.WareHouseId); model.Add(m); } return(model); }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { if (Convert.ToInt32(ddlVendorId.SelectedValue) != -1) { string ProductCode = txtProductCode.Text; string ProductName = txtProductName.Text; string ProductTag1 = txtProductTag1.Text; string ProductTag2 = txtProductTag2.Text; string ProductManufacturer = txtProductManufacturer.Text; string ProductDescription = txtProductDescription.Text; string ProductVendorId = ddlVendorId.SelectedValue; string CostPrice = txtCostPrice.Text; string SalePrice = txtSalePrice.Text; Models.MProducts mv = new Models.MProducts(); mv.ProductCode = ProductCode; mv.Name = ProductName; mv.tag1 = ProductTag1; mv.tag2 = ProductTag2; mv.CostPrice = CostPrice; mv.SalePrice = SalePrice; mv.Manufacturer = ProductManufacturer; mv.description = ProductDescription; mv.Vendorld = ProductVendorId; mv.WareHouseId = Session["WareHouse"].ToString(); Classes.CProducts ccv = new Classes.CProducts(); if (ccv.Save(mv) < 0) { ShowFailMessage(); } else { ShowSuccessMessage(); ClearTextBoxes(Page); } } else { ShowErrorMessage("Please select a Vendor"); } } else { } }
public List <Models.MProducts> GetAll() { List <Models.MProducts> list = new List <Models.MProducts>(); var q = from o in DBMod.CDBHandler.cdc.ProductMasters select o; foreach (var item in q) { Models.MProducts model = new Models.MProducts(); model.id = item.id.ToString(); model.Name1 = item.Name1; model.Name2 = item.Name2; model.Name3 = item.Name3; model.Price = item.Price; model.ImageUrl1 = item.ImageUrl1; model.ImageUrl2 = item.ImageUrl2; model.ImageUrl3 = item.ImageUrl3; model.Description = item.Description; model.Code = item.Code; list.Add(model); } return(list); }
public int Delete(Models.MProducts model) { Common.Logger l = new Common.Logger(); string ClassName = "CProduct"; try { var query = from o in obj.Products where Convert.ToString(o.id) == model.id select o; foreach (var item in query) { obj.Products.DeleteOnSubmit(item); } l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductCode[" + model.ProductCode + "] Name[" + model.Name + "] tag1[" + model.tag1 + "] tag2[ " + model.tag2 + "] tag3 [" + model.tag3 + " ] Manufacture[ " + model.Manufacturer + " ] Description [ " + model.description + "] VendorId [ " + model.Vendorld + "] FiscalYearId [ " + model.FiscalYearld + "] eDate[ " + model.eDate + "]"); obj.SubmitChanges(); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Deleted Successfully"); return(1); } catch (Exception ex) { l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
public int Save(Models.MProducts mp) { try { DBMod.ProductMaster pm = new DBMod.ProductMaster(); pm.Code = mp.Code; pm.Description = mp.Description; pm.ImageUrl1 = mp.ImageUrl1; pm.ImageUrl2 = mp.ImageUrl2; pm.ImageUrl3 = mp.ImageUrl3; pm.Name1 = mp.Name1; pm.Name2 = mp.Name2; pm.Name3 = mp.Name3; pm.Price = mp.Price; DBMod.CDBHandler.cdc.ProductMasters.InsertOnSubmit(pm); DBMod.CDBHandler.cdc.SubmitChanges(); return(1); } catch { return(-1); } }
protected void btnSave_Click(object sender, EventArgs e) { string ProductId = lblProductid.Text; string ProductCode = txtProductcode.Text; string ProductName = txtProductName.Text; string ProductTag1 = txtProducttag1.Text; string ProductTag2 = txtProducttag2.Text; string ProductManufacturer = txtProductManufacturer.Text; string ProductDescription = txtProductDescription.Text; string CostPrice = txtCp.Text; string SalePrice = txtSp.Text; Models.MProducts mv = new Models.MProducts(); mv.id = ProductId; mv.ProductCode = ProductCode; mv.Name = ProductName; mv.tag1 = ProductTag1; mv.tag2 = ProductTag2; mv.CostPrice = CostPrice; mv.SalePrice = SalePrice; mv.Manufacturer = ProductManufacturer; mv.description = ProductDescription; mv.Vendorld = ddlVendorId.SelectedValue; Classes.CProducts ccv = new Classes.CProducts(); if (ccv.Update(mv) < 0) { ShowFailMessage(); } else { ShowSuccessMessage(); BindData(); ClearTextBoxes(Page); } }
public int Update(Models.MProducts model) { Common.Logger l = new Common.Logger(); string ClassName = "CProduct"; try { var query = from o in obj.Products where Convert.ToString(o.id) == model.id select o; foreach (var item in query) { item.id = int.Parse(model.id); item.ProductCode = model.ProductCode; item.Name = model.Name; item.tag1 = model.tag1; item.tag2 = model.tag1; item.tag3 = model.tag3; item.salePrice = model.SalePrice; item.costPrice = model.CostPrice; item.Manufacturer = model.Manufacturer; item.Description = model.description; item.VendorId = int.Parse(model.Vendorld); item.FiscalYearId = Convert.ToInt32(model.FiscalYearld); item.eDate = Convert.ToDateTime(model.eDate); } l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductCode[" + model.ProductCode + "] Name[" + model.Name + "] tag1[" + model.tag1 + "] tag2[ " + model.tag2 + "] tag3 [" + model.tag3 + " ] Manufacture[ " + model.Manufacturer + " ] Description [ " + model.description + "] VendorId [ " + model.Vendorld + "] FiscalYearId [ " + model.FiscalYearld + "] eDate[ " + model.eDate + "]"); obj.SubmitChanges(); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully"); return(1); } catch (Exception ex) { l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }