public ActionResult Products(SearchModel search) { BDContext db = new BDContext(); ProdModel PModel = new ProdModel(); if (search.Mark == null) { search.Mark = ""; } if (search.Model == null) { search.Model = ""; } if (search.MaxPrice == 0) { search.MaxPrice = 999999999999999; } var PModelLst = new List <ProdModel>(); var PModelQuery = from mark in db.Marks join model in db.Models on mark.Id equals model.IdMark join modification in db.Modifications on model.Id equals modification.IdModel select new ProdModel { Mark = mark.Mark, Model = model.Model, IdMark = mark.Id, IdModel = model.Id, Price = modification.Price, Picture = model.Picture }; var PriceQuery = from m in PModelQuery where m.Mark.Contains(search.Mark) && m.Model.Contains(search.Model) && m.Price <= search.MaxPrice && m.Price >= search.MinPrice group m by new { m.IdModel, m.IdMark, m.Mark, m.Model, m.Picture } into g select new ProdModel { Mark = g.Key.Mark, Model = g.Key.Model, IdMark = g.Key.IdMark, IdModel = g.Key.IdModel, Price = g.Min(m => m.Price), Picture = g.Key.Picture }; PriceQuery.ToList(); PModelLst.AddRange(PriceQuery.Distinct()); ViewBag.PModelLst = PModelLst; return(View()); }
public List <ProdModel> LKU_Prod_ByPWC(string pwc) { List <ProdModel> pList = new List <ProdModel>(); SqlCommand cmd = new SqlCommand(); SqlDataReader rdr = default(SqlDataReader); SqlConnection conn = new SqlConnection(STRATIXDataConnString); using (conn) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ST_PROD_LKU_proc_MTY_ByPWC"; cmd.Connection = conn; AddParamToSQLCmd(cmd, "@pwc", SqlDbType.VarChar, 3, ParameterDirection.Input, pwc); rdr = cmd.ExecuteReader(); using (rdr) { while (rdr.Read()) { ProdModel p = new ProdModel(); p.workDy = (int)rdr["WORK_DY"]; p.prodDt = (int)rdr["PROD_DT"]; p.pwc = (string)rdr["PWC"]; p.jobs = (int)rdr["JOBS"]; p.lbs = (int)rdr["LBS"]; p.brks = (int)rdr["BRKS"]; p.setUps = (int)rdr["SETUPS"]; pList.Add(p); } } } return(pList); }
public override void DeleteRec() { base.DeleteRec(); if (customGridView1.FocusedRowHandle < 0) { return; } try { var _id = Convert.ToInt32(this.customGridView1.GetRowCellValue(customGridView1.FocusedRowHandle, "Id")); var _vid = Convert.ToInt32(this.customGridView1.GetRowCellValue(customGridView1.FocusedRowHandle, "VoucherId")); var _deleted = Convert.ToBoolean(this.customGridView1.GetRowCellValue(customGridView1.FocusedRowHandle, "IsDeleted")); // var _status = this.customGridView1.GetRowCellValue(customGridView1.FocusedRowHandle, "Status").ToString(); if (_deleted) { MessageBoxAdv.Show("Record Already in Deleted State", "Delete !!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBoxAdv.Show(KontoGlobals.DeleteBeforeMsg, "Delete ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } using (var db = new KontoContext()) { var model = db.Challans.Find(_id); bool result = LedgerEff.DataFreezeStatus(model.VoucherDate, model.TypeId, db); if (result == false) { MessageBox.Show(KontoGlobals.DeleteFreezeWarning); return; } var trans = db.ChallanTranses.Where(x => x.ChallanId == _id).ToList(); foreach (var ct in trans) { var delProdOut = db.ProdOuts.Where(p => p.TransId == ct.Id && p.RefId == model.Id).ToList(); //Challan Trans ct.IsDeleted = true; foreach (var poitem in delProdOut) { ProdModel pitem = db.Prods.Find(poitem.ProdId); if (pitem != null && pitem.RefId != model.Id && pitem.TransId != ct.Id && pitem.VoucherId != model.VoucherId) { pitem.ProdStatus = "STOCK"; } else { pitem.IsDeleted = true; } poitem.IsDeleted = true; } ct.IsDeleted = true; } var stk = db.StockTranses.Where(k => k.MasterRefId == model.RowId).ToList(); if (stk != null) { db.StockTranses.RemoveRange(stk); } model.IsDeleted = true; db.SaveChanges(); customGridView1.DeleteRow(customGridView1.FocusedRowHandle); MessageBoxAdv.Show(KontoGlobals.DeleteAfterMsg, "Delete !!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Log.Error(ex, "Store Issue delete"); MessageBoxAdv.Show(this, "Error While Delete !!", "Exception ", ex.ToString()); } }
public ActionResult Edit(int id, ProdModel obj) { HttpResponseMessage response = GlobalClient.webApiClient.PutAsJsonAsync("ProductsTables/" + obj.Pid, obj).Result; return(RedirectToAction("Index")); }
public ActionResult Create(ProdModel obj) { HttpResponseMessage response = GlobalClient.webApiClient.PostAsJsonAsync("ProductsTables", obj).Result; return(RedirectToAction("Index")); }