/*DataWriters*/ public Norms SaveNorms(Norms norm) { SqlServerConnection conn = new SqlServerConnection(); norm.Id = conn.SqlServerUpdate("DECLARE @fac INT=" + norm.Facility.Id + " , @norm INT=" + norm.Item.Id + ", @val INT=" + norm.Value + ", @fem INT=" + norm.Female + ", @mal INT=" + norm.Male + ", @dis INT=" + norm.Disabled + "; IF NOT EXISTS (SELECT nr_idnt FROM Norms WHERE nr_facility=@fac AND nr_norm=@norm) BEGIN INSERT INTO Norms(nr_facility, nr_norm, nr_available, nr_female, nr_male, nr_disabled) output INSERTED.nr_idnt VALUES (@fac, @norm, @val, @fem, @mal, @dis) END ELSE BEGIN UPDATE Norms SET nr_available=@val, nr_female=@fem, nr_male=@mal, nr_disabled=@dis output INSERTED.nr_idnt WHERE nr_facility=@fac AND nr_norm=@norm END"); return(norm); }
public int AddNorms(dynamic requestData) { string query = JsonConvert.SerializeObject(requestData); Norms norms = JsonConvert.DeserializeObject <Norms>(query); db.Norms.Add(norms); return(db.SaveChanges()); }
public int UpdateNorms(dynamic requestData) { string query = JsonConvert.SerializeObject(requestData); Norms norms = JsonConvert.DeserializeObject <Norms>(query); EntityState statebefore = db.Entry(norms).State; db.Entry(norms).State = EntityState.Modified; return(db.SaveChanges()); }
public async Task <IActionResult> PostPTV(Norms sss) { //var norms = new Norms { CategoryesId = 2 }; //await _context.Norms.AddAsync(norms); //await _context.SaveChangesAsync(); //foreach (var item in await _context.PTV.ToListAsync()) //{ // await _context.Norms_PTVs.AddAsync(new Norms_PTV { NormsId = norms.NormsId, PTVId = item.PTVId, NormsCount = 0, WarehouseNormsCount = 0 }); //} //await _context.SaveChangesAsync(); return(View()); }
public List <Norms> GetNorms(Facility facility, Int64 type, Boolean includeZeros = false, Boolean filterServices = false) { List <Norms> norms = new List <Norms>(); string AdditionalQuery = " AND NOT (nt_norm=0 AND NULLIF(nr_available,0) IS NULL)"; string ServicesQuery = ""; if (includeZeros) { AdditionalQuery = ""; } if (filterServices) { ServicesQuery = "AND nc_idnt IN (SELECT ns_category FROM NormsServices WHERE ns_level=" + facility.Category.Level.Id + ")"; } SqlServerConnection conn = new SqlServerConnection(); SqlDataReader dr = conn.SqlServerConnect("SELECT nc_idnt, nc_category, ni_idnt, ni_item, nt_norm, ISNULL(nr_available,0) nt_avail, ISNULL(nr_female,0) nt_female, ISNULL(nr_male,0)_nt_male, ISNULL(nr_disabled,0) nt_disabled FROM NormsTiers INNER JOIN NormsItems ON nt_item=ni_idnt AND ni_type=" + type + " INNER JOIN NormsCategory ON ni_catg=nc_idnt " + ServicesQuery + " LEFT OUTER JOIN Norms ON nt_item=nr_norm AND nr_facility=" + facility.Id + " WHERE nt_tctg=" + facility.Category.Id + AdditionalQuery + " ORDER BY ni_catg, nt_item"); if (dr.HasRows) { while (dr.Read()) { Norms norm = new Norms(); norm.Item.Category.Id = Convert.ToInt64(dr[0]); norm.Item.Category.Name = dr[1].ToString(); norm.Item.Id = Convert.ToInt64(dr[2]); norm.Item.Name = dr[3].ToString(); norm.Norm = Convert.ToInt64(dr[4]); norm.Value = Convert.ToInt64(dr[5]); norm.Female = Convert.ToInt64(dr[6]); norm.Male = Convert.ToInt64(dr[7]); norm.Disabled = Convert.ToInt64(dr[8]); if (norm.Value > norm.Norm) { norm.Gaps = 0; } else { norm.Gaps = norm.Norm - norm.Value; } norms.Add(norm); } } return(norms); }
public ProductInMenu(int Id, string Name, float Price, int dishId, float Norm, int Kids, int KidsB, bool B) { if (!B) { this.Id = Id; this.Name = Name; this.Price = Price; this.Norms = new Dictionary <int, float>(); Norms.Add(dishId, Norm); this.SumNorms = SetSumm(); this.TotalOfKids = Math.Round((Kids + KidsB) * SumNorms, 2); } else { this.Id = Id; this.Name = Name; this.Price = Price; this.Norms = new Dictionary <int, float>(); this.SumNorms = Math.Round((((14 * KidsB) / Price) / KidsB), 3); this.TotalOfKids = Math.Round(KidsB * SumNorms, 2); } }