private void CreateItem() { DataAccess da = new DataAccess(); brand item = new brand(); item.name = edtName.Text; item.description = edtDescr.Text; da.BrandCreate(item); }
private void EditItem() { DataAccess da = new DataAccess(); brand item = new brand(); item.id = _id; item.name = edtName.Text; item.description = edtDescr.Text; da.BrandEdit(item); }
public static List<brand> getBrands(string FilePath) { List<brand> brands = new List<brand>(); // Объявляем и забиваем файл в документ XmlDocument xd = new XmlDocument(); FileStream fs = new FileStream(FilePath, FileMode.Open); xd.Load(fs); XmlNodeList list = xd.GetElementsByTagName("Row"); // Создаем и заполняем лист по тегу "user" for (int i = 0; i < list.Count; i++) { brand b = new brand(); b.code1C = list[i].FirstChild.InnerText; b.name = list[i].LastChild.InnerText; brands.Add(b); } // Закрываем поток fs.Close(); return brands; }
/// <summary> /// Deprecated Method for adding a new object to the brands EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTobrands(brand brand) { base.AddObject("brands", brand); }
/// <summary> /// Create a new brand object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the name property.</param> public static brand Createbrand(global::System.Int32 id, global::System.String name) { brand brand = new brand(); brand.id = id; brand.name = name; return brand; }
public void BrandEdit(brand item) { brand original = objDataContext.brands.FirstOrDefault(b => b.id == item.id); if (original != null) { original.name = item.name; original.description = item.description; //if (original.created_on == null) // original.created_on = DateTime.Now; objDataContext.SaveChanges(); } }
public brand BrandCreate(brand _obj) { //_obj.created_on = DateTime.Now; objDataContext.AddTobrands(_obj); objDataContext.SaveChanges(); return _obj; }
public spare SpareCreateSilent(string Name, string CodeShatem, string GroupName, string ParentGroupName, string BrandName, string UnitName, string Description) { // получим группу //spare_group ParentGroup = objDataContext.spare_group.FirstOrDefault(i => i.id == 1).spare_group1.FirstOrDefault(x => x.name.ToUpper() == ParentGroupName.ToUpper()); List<spare_group> groups = objDataContext.spare_group.Where(i => i.ParentGroup.id == 1).ToList(); // все группы, дочерние группе #1 groups = groups.Where(i => i.name.ToUpper().Equals(ParentGroupName.ToUpper())).ToList(); spare_group ParentGroup = null; if (groups.Count > 0) ParentGroup = groups[0]; if (ParentGroup == null) { // создать новую группу spare_group sgNew = new spare_group(); sgNew.name = ParentGroupName; spare_group root = objDataContext.spare_group.FirstOrDefault(x => x.id == 1); sgNew.ParentGroup = root; sgNew.IsBrand = false; sgNew.ChildCount = 0; sgNew.code1C = ""; sgNew.description = ""; sgNew.ParentGroupName = root.name; objDataContext.AddTospare_group(sgNew); objDataContext.SaveChanges(); ParentGroup = sgNew; } // получим подгруппу //spare_group group = objDataContext.spare_group.FirstOrDefault(i => i.id == ParentGroup.id).spare_group1.FirstOrDefault(x => x.name.ToUpper() == GroupName.ToUpper()); groups = objDataContext.spare_group.Where(i => i.ParentGroup.id == ParentGroup.id).ToList(); groups = groups.Where(i => i.name.ToUpper().Equals(GroupName.ToUpper())).ToList(); spare_group group = null; if (groups.Count > 0) group = groups[0]; if (group == null) { // создать новую группу spare_group sgNew = new spare_group(); sgNew.name = GroupName; spare_group parent = objDataContext.spare_group.FirstOrDefault(x => x.id == ParentGroup.id); sgNew.ParentGroup = parent; sgNew.IsBrand = false; sgNew.ChildCount = 0; sgNew.code1C = ""; sgNew.description = ""; sgNew.ParentGroupName = parent.name; parent.ChildCount++; objDataContext.AddTospare_group(sgNew); objDataContext.SaveChanges(); group = sgNew; } // получим брэнд brand b = objDataContext.brands.FirstOrDefault(i => i.name == BrandName); if (b == null) { brand bNew = new brand(); bNew.name = BrandName; objDataContext.AddTobrands(bNew); objDataContext.SaveChanges(); b = bNew; } // получим unit unit u = objDataContext.units.FirstOrDefault(x => x.name == UnitName); if (u == null) { unit bNew = new unit(); bNew.name = UnitName; objDataContext.AddTounits(bNew); objDataContext.SaveChanges(); u = bNew; } spare sp = new spare(); sp.name = Name; sp.code = ""; sp.codeShatem = CodeShatem; sp.q_demand = 0; sp.q_demand_clear = 0; sp.q_rest = 0; sp.description = Description; sp.spare_group1 = ParentGroup; sp.spare_group = group; int GroupID = group.id; sp.brand = b; sp.unit = u; // [spare_group2_id] if (sp.spare_group1.ParentGroup != null) { spare_group group2 = objDataContext.spare_group.FirstOrDefault(x => x.id == sp.spare_group1.ParentGroup.id); if (group2 != null) { sp.spare_group2 = group2; // [spare_group3_id] if (group2.ParentGroup != null) { spare_group group3 = objDataContext.spare_group.FirstOrDefault(x => x.id == group2.ParentGroup.id); if (group3 != null) sp.spare_group3 = group3; } } } // [BrandName] sp.BrandName = sp.brand.name; // [GroupName] sp.GroupName = sp.spare_group.name; // [ParentGroupName] sp.ParentGroupName = sp.spare_group1.name; objDataContext.AddTospares(sp); objDataContext.SaveChanges(); //spare s = SpareCreate(sp, sp.brand.id, sp.spare_group.id, b.id); return sp; }
public void SpareCreate(string GrandParentGroupName, string ParentGroupName, string BrandName, string SpareCode, string SpareName, string SpareCars) { if (GrandParentGroupName.Equals(ParentGroupName)) ParentGroupName += "_"; // ============================================= // grand pa group spare_group gsg = null; //get group gsg = objDataContext.spare_group.FirstOrDefault(i => i.name.Equals(GrandParentGroupName)); if (gsg == null) { // create new brand gsg = new spare_group(); gsg.name = GrandParentGroupName; gsg.ParentGroup = root; objDataContext.AddTospare_group(gsg); objDataContext.SaveChanges(); } // ============================================= // pa group spare_group sg = null; //get group sg = objDataContext.spare_group.FirstOrDefault(i => i.name.Equals(ParentGroupName)); if (sg == null) { // create new brand sg = new spare_group(); sg.name = ParentGroupName; sg.ParentGroup = gsg; objDataContext.AddTospare_group(sg); objDataContext.SaveChanges(); } // ============================================= // brand brand b = null; //get brand b = objDataContext.brands.FirstOrDefault(i => i.name.Equals(BrandName)); if (b == null) { // create new brand b = new brand(); b.name = BrandName; objDataContext.AddTobrands(b); objDataContext.SaveChanges(); } // spare spare s = new spare(); s.spare_group2 = root; s.spare_group1 = gsg; s.spare_group = sg; s.brand = b; // ============================================= // code s.code = SpareCode; // ============================================= // name + models s.name = SpareName + "( " + SpareCars + ")"; // ============================================= // defs s.description = ""; s.q_rest = 0; s.q_demand = 0; s.cashless = 0; s.unit = u; s.q_demand_clear = 0; s.codeShatem = ""; // add & save objDataContext.AddTospares(s); objDataContext.SaveChanges(); }