// //CRUD OPERATION TO ADD NEW DATA TO SGM public int AddData(int SID, string UGC, string Desc, string Abbrev, Nullable<int> Val, string SCC, Nullable<int> Seq) { var allItem = from m in db.SGMs select m; var getGID_count = from m in db.SGMs .Where(c => c.SID == SID) select m.SID; int count = getGID_count.Count(); int gid = count + 1; if (UGC.Length == 0) { UGC = null; } if (Desc.Length == 0) { Desc = null; } if (Abbrev.Length == 0) { Abbrev = null; } if (SCC.Length == 0) { SCC = null; } gid = Convert.ToInt32(SID.ToString() + gid.ToString()); if (allItem.Any(c => c.GID.ToString().ToLower().Equals(gid.ToString().ToLower()))) { Response.Write("Item with the ID '" + gid + "' already exists"); Response.StatusCode = 404; Response.End(); return -1; } var pushSGM = new SGM(); pushSGM.GID = gid; pushSGM.SID = SID; pushSGM.UGC = UGC.ToUpper(); pushSGM.Desc = Desc.ToUpper(); pushSGM.Abbrev = Abbrev.ToUpper(); pushSGM.Val = Val; pushSGM.SCC = SCC.ToUpper(); pushSGM.Seq = Seq; db.SGMs.InsertOnSubmit(pushSGM); db.SubmitChanges(); //Response.End(); return pushSGM.GID; }
partial void DeleteSGM(SGM instance);
partial void UpdateSGM(SGM instance);
partial void InsertSGM(SGM instance);