public NewprocessesViewModel() { back = new Command(() => { Ico.getValue <ContentApp>().back(); }); save = new Command(async() => { erour = new List <string>(); if (Name.ToString().Length == 0) { erour.Add("الرجاء كتابة إسم العملية "); } if (Code.ToString().Length != 15) { erour.Add(" كود العملية يجب أن يحتوي على 15 حرف"); } if (Num.ToString().Length == 0) { erour.Add("الرجاء كتابة رقم الثابت للعملية "); } else { string pattern = "[1-9]+/[1-9]+"; Regex rgx = new Regex(pattern); if (!rgx.IsMatch(Num.ToString())) { erour.Add("الرجاء كتابة رقم الثابت بشكل الصحيح ##/## "); } } if (erour.Count == 0) { AcceptSample4Dialog(); await Task.Run(() => { double totalCoast = 0; var p = new process() { Name = Name, date = date, Code = Code, num = Num, NewCost = totalCoast, location = Ico.getValue <IO>().CREATE_F_PRO(Code), edit = true }; Ico.getValue <db>().GetUnivdb().processes.Add(p); Ico.getValue <db>().GetUnivdb().SaveChanges(); CancelSample4Dialog(); }); Ico.getValue <ContentApp>().back(); Ico.getValue <ContentApp>().clear(); } else { OpenSample4Dialog(); Sample4Content = new Messagebox(erour, () => { CancelSample4Dialog(); }); } }); }
private void CancelSample4Dialog() { IsSample4DialogOpen = false; this.inTilData(Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(c => c.id == card_kanoni.id).ToList().SingleOrDefault()); }
public Addsa7abiVewModel(process process) { this.namepro = process.Name; this.Cost = process.NewCost; // this.date = Ico.getValue<Date>().GetPevDate().year1.Year + "/12/31"; Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(process)); IEnumerable <card_dafa3> get_data(process p) { var cs = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.part.Id_Pro == p.Id && c.tswiya == null).ToList(); foreach (var c in cs) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == c.id_part).First().nowcost -= c.Cost; Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == c.id_part).First().mcost += c.Cost; } Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(cs); return(cs); } var dm = 0d; var dn = 0d; foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { foreach (var m in p.card_mo7sabi.ToList().Where(c => c.visa == null).ToList()) { Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pr => pr.Id == process.Id).ToList().First().NewCost += m.cost; Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == m.id_part).First().mcost -= m.cost; Ico.getValue <db>().GetUnivdb().card_mo7sabi.Remove(Ico.getValue <db>().GetUnivdb().card_mo7sabi. ToList().Where(c => c.Id == m.Id).ToList().SingleOrDefault()); Ico.getValue <db>().GetUnivdb().cards.Remove(Ico.getValue <db>().GetUnivdb().cards. ToList().Where(c => c.Id == m.id_card).ToList().SingleOrDefault()); } dn += Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().nowcost; dm += Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().mcost; } Ico.getValue <db>().savedb(); this.sa7abCost = dm - dn; savecommand = new Command(() => { var car = new card() { date = DateTime.Now, id_prosess = process.Id, num = 1, year = Ico.getValue <db>().GetUnivdb().years.ToList().LastOrDefault().Id, location = "" }; var card_sa7ab = new card_sa7ab() { cost = sa7abCost, card = car, visa = null, old_cost = Cost }; Ico.getValue <db>().GetUnivdb().processes.ToList().Where(p => p.Id == process.Id).ToList().First().NewCost += sa7abCost; Ico.getValue <db>().GetUnivdb().cards.Add(car); Ico.getValue <db>().GetUnivdb().card_sa7ab.Add(card_sa7ab); foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().mcost - p.nowcost; } Ico.getValue <db>().savedb(); con(); }); Cancelcommand = new Command(() => { con(); }); }
public SettingModelView() { val = Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault(); TempalePath = val.locationTem; PathFileSave = val.locationFile; date = DateTime.Now; PathFileSavec = new Command(() => { var folderDialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); var folderResult = folderDialog.ShowDialog(); if (folderResult.HasValue && folderResult.Value) { PathFileSave = folderDialog.SelectedPath; } }); TempalePathc = new Command(() => { var folderDialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); var folderResult = folderDialog.ShowDialog(); if (folderResult.HasValue && folderResult.Value) { TempalePath = folderDialog.SelectedPath; } }); savecommand = new Command(() => { erour = new List <string>(); if (PathFileSave.ToString().Length == 0) { erour.Add("الرجاء كتابة مسار حفظ الملفات "); } if (TempalePath.ToString().Length == 0) { erour.Add("الرجاء كتابة مسار قوالب "); } if (date == null) { erour.Add("الرجاء تحديد تاريخ البرنامج "); } else { if (Ico.getValue <Date>().GetNowDate().year1.Year > date.Year) { erour.Add("الرجاء تحديد تاريخ صحيح "); } } Ico.getValue <ContentApp>().OpenSample4Dialog(); if (erour.Count != 0) { Ico.getValue <ContentApp>().Sample4Content = new Messagebox(erour, () => { Ico.getValue <ContentApp>().CancelSample4Dialog(); }); } else { if (Ico.getValue <Date>().GetNowDate().year1.Year != date.Year) { Ico.getValue <ContentApp>().Sample4Content = new YesOrNo("هل تريد تغير تاريخ البرنامج ذالك سيغر الكثر في البرناج الرجاء الحذر ...", () => { Ico.getValue <db>().GetUnivdb().years.Add(new year() { year1 = date }); Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().locationFile = PathFileSave; Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().locationTem = TempalePath; Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().date = date; Ico.getValue <db>().savedb(); Ico.ResetValue <Date>(new Date()); Ico.ResetValue <setting>(Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault()); Ico.ResetValue <IO>(new IO()); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "تم التعديل بنجاح.. " }, Ico.getValue <ContentApp>().CancelSample4Dialog); }, () => { Ico.getValue <ContentApp>().CancelSample4Dialog(); }); } else { Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().locationFile = PathFileSave; Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().locationTem = TempalePath; Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault().date = date; Ico.getValue <db>().savedb(); Ico.ResetValue <Date>(new Date()); Ico.ResetValue <setting>(Ico.getValue <db>().GetUnivdb().settings.ToList().FirstOrDefault()); Ico.ResetValue <IO>(new IO()); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "تم التعديل بنجاح.. " }, Ico.getValue <ContentApp>().CancelSample4Dialog); } } }); }
public ItemMo7asabi(card_mo7sabi card_mo7sabi) { this.Cost = String.Format("{0:0.00}", card_mo7sabi.cost); this.num = card_mo7sabi.card.num; this.date = card_mo7sabi.card.date;; this.oldcost = String.Format("{0:0.00}", card_mo7sabi.oldCost); this.nowcost = String.Format("{0:0.00}", card_mo7sabi.oldCost - card_mo7sabi.cost); visibility = Visibility.Visible; tashiravis = Visibility.Visible; edittashiravis = Visibility.Collapsed; if (card_mo7sabi.visa != null) { visibility = Visibility.Collapsed; edittashiravis = Visibility.Visible; tashiravis = Visibility.Collapsed; visa = card_mo7sabi.visa; } edit = new Command(() => { action_edit(card_mo7sabi); }); open = new Command(() => { Card_mo7asabiExecl card_ = new Card_mo7asabiExecl(card_mo7sabi); card_.CreateCard(); }); tashira = new Command(() => { bool can = true; foreach (var c in Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.part.Id_Pro == Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().id_prosess&& c.card.date < Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().date)) { if (c.visa == null) { can = false; break; } } if (can) { MessageBox.Show("هنالك بطاقة "); addtashira(card_mo7sabi); } else { MessageBox.Show("هنالك بطاقة ليست لها تأشيرة قبل هذه البطاقة "); } }); edittashira = new Command(() => { edittashiraaction(card_mo7sabi); }); remove = new Command(() => { start(); Ico.getValue <db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_mo7sabi.part.Id_Pro).ToList().SingleOrDefault().NewCost += card_mo7sabi.cost; Ico.getValue <db>().changedNumCard(card_mo7sabi.card); Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(card_mo7sabi)); IEnumerable <card_dafa3> get_data(card_mo7sabi card) { var cs = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => (c.id_part == card_mo7sabi.id_part) && (c.tswiya == null) && (c.date > card_mo7sabi.card.date)); foreach (var c in cs) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(p => p.Id == card_mo7sabi.id_part).First().nowcost -= c.Cost; } return(cs); } foreach (var c in Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.part.Id_Pro == Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().id_prosess&& c.card.date > Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().date)) { Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(ca => ca.Id == c.Id).ToList().FirstOrDefault().oldCost += card_mo7sabi.cost; Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(ca => ca.Id == c.Id).ToList().FirstOrDefault().num -= 1; } Ico.getValue <db>().GetUnivdb().card_mo7sabi.Remove(Ico.getValue <db>().GetUnivdb().card_mo7sabi. ToList().Where(c => c.Id == card_mo7sabi.Id).ToList().SingleOrDefault()); Ico.getValue <db>().GetUnivdb().cards.Remove(Ico.getValue <db>().GetUnivdb().cards. ToList().Where(c => c.Id == card_mo7sabi.id_card).ToList().SingleOrDefault()); Ico.getValue <db>().savedb(); end(); }); add_Mo7asabi = new Command(() => { // Ico.getValue<ContentApp>().page = new AddPartCard(part); // action_Mo7asabi(); }); }
public void inTilData() { this.actionUP(); this.name = val.Name; this.code = val.Code; this.num = val.num; var lc = val.cards; if (lc.ToList().Count > 0) { var a = lc.ToList().Where(c => c.card_7isab.Count > 0).FirstOrDefault(); if (a != null) { if (a.card_7isab?.ToList().FirstOrDefault() != null && a.card_7isab?.ToList().FirstOrDefault().visa != null) { visibility = Visibility.Collapsed; } } } this.date = val.date.GetDateTimeFormats()[0]; this.nowcost = val.NewCost; parts = new ObservableCollection <ItemPart>(val.parts.ToList().Select(p => new ItemPart(p) { action = (t) => { var prr = Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).FirstOrDefault(); if (prr.card_kanoni.ToList().Count == 0) { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new YesOrNo("هل أنت متأكد من قيامك بحذف هذه الحصة من العملية ,لا يمكن التراجع عن الحذف", async() => { AcceptSample4Dialog(); await Task.Run(() => { Ico.getValue <db>().GetUnivdb().parts.Remove(prr); Ico.getValue <db>().savedb(); CancelSample4Dialog(); }); parts.Remove(t); }, Ico.getValue <ContentApp>().CancelSample4Dialog); } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء حذف جميع البطاقات الخاصة بالحصة ومن ثم أعد المحاولة مرة أخرى " }, Ico.getValue <ContentApp>().CancelSample4Dialog); } }, action_kanoni = () => { var card = Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(c => c.id_part == p.Id).FirstOrDefault(); if (card == null) { Sample4Content = new AddPartCard(p, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); } else { Ico.getValue <ContentApp>().page = new Viewkanoni(card); } } })); }
private void CancelSample4Dialog() { IsSample4DialogOpen = false; this.inTilData(Ico.getValue <db>().GetUnivdb().parts.ToList().Where(p => p.Id == part.part.Id).ToList().SingleOrDefault()); }
public AddclientVievModel() { save = new Command(async() => { erour = new List <string>(); if (Name.ToString().Length == 0) { erour.Add("الرجاء كتابة إسم العميل"); } if (numaccount.ToString().Length == 0) { erour.Add("الرجاء كتابة رقم الحساب "); } if (agence.ToString().Length == 0) { erour.Add("الرجاء كتابة الوكالة "); } if (bank.ToString().Length == 0) { erour.Add("الرجاء كتابة البنك "); } if (address.ToString().Length == 0) { erour.Add("الرجاء كتابة العنوان "); } OpenSample4Dialog(); if (erour.Count == 0) { AcceptSample4Dialog(); await Task.Run(() => { var client = new client() { Name = Name, address = address, bank = bank, gence = agence, num_account = numaccount }; Ico.getValue <db>().GetUnivdb().clients.Add(client); Ico.getValue <db>().savedb(); Ico.getValue <ContentApp>().back(); }); } else { Sample4Content = new Messagebox(erour, () => { CancelSample4Dialog(); }); } }); back = new Command(() => { }); }
public Addsa7abiVewModel(process process) { this.namepro = process.Name; this.Cost = process.NewCost; this.date = Ico.getValue <Date>().GetPevDate().year1.Year + "/12/31"; Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(process)); IEnumerable <card_dafa3> get_data(process p) { var cs = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.part.Id_Pro == p.Id && c.tswiya == null).ToList(); foreach (var c in cs) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == c.id_part).First().nowcost -= c.Cost; } Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(cs); return(cs); } foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { double ps = 0d; foreach (var m in p.card_mo7sabi.ToList().Where(c => c.visa != null).ToList()) { ps += m.cost; } ps -= p.nowcost; sa7abCost += ps; } // var carda = Ico.getValue<db>().GetUnivdb().years.Where(y => y.year1.Year == DateTime.Now.Year).ToList().FirstOrDefault().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro) // .ToList().FirstOrDefault(); /* var carda = Ico.getValue<db>().GetUnivdb().card_mo7sabi.ToList().Where(c => (c.card.year1.Id == Ico.getValue<db>().GetUnivdb().years.ToList() * .Where(y => y.year1.Year == DateTime.Now.Year).ToList().FirstOrDefault().Id)&& c.id_part == card_kanoni.id_part) * .ToList().OrderByDescending(c => c.num).ToList().FirstOrDefault(); * //.card_mo7sabi.Where(c=>c.id_part== card_kanoni.id_part).OrderByDescending(c=>c.num).LastOrDefault(); * * var numm = 1; * if (carda != null) { * numm = carda.num + 1; * MessageBox.Show("" + carda.num); * } * var nums = (numm.ToString().Length == 1) ? "0" + numm.ToString() : numm.ToString(); */ savecommand = new Command(() => { /* * var d = 0d; * foreach (var c in part.card_mo7sabi.ToList()) * { * d += c.cost; * } * if ((part.Cost - d) >= Cost) * { * acc(); * * var card = Ico.getValue<db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro).OrderByDescending(c => c.num).ToList().FirstOrDefault(); * var num = 1; * if (card != null) * { * num = card.num + 1; * } * * * var car = new card() * { * date = DateTime.Now, * id_prosess = card_kanoni.part.Id_Pro, * num = Ico.getValue<db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro).LastOrDefault().num + 1, * year = Ico.getValue<db>().GetUnivdb().years.ToList().LastOrDefault().Id * , * location = "" * }; * var card_mo7sabi = new card_mo7sabi() * { * id_client = card_kanoni.id_client, * id_part = card_kanoni.id_part, * cost = Cost, * oldCost = card_kanoni.part.process.NewCost, * card = car, * num = numm, * visa = null, * subject = subject * * * }; * * Ico.getValue<db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_kanoni.part.Id_Pro).ToList().First().NewCost -= Cost; * Ico.getValue<db>().GetUnivdb().cards.Add(car); * Ico.getValue<db>().GetUnivdb().card_mo7sabi.Add(card_mo7sabi); * Ico.getValue<db>().savedb(); * * con(); * } * else { * * MessageBox.Show("المبلغ أكبر من الرصيد المتاح"); * * }*/ }); Cancelcommand = new Command(() => { con(); }); }
public void inTilData(part part) { this.process = part.process; this.part = new Part(part); ItemDafa3S = CreateItem(); double d = 0; foreach (var m in part.card_mo7sabi.ToList().Where(c => c.card.date.Year == Ico.getValue <Date>().GetNowDate().year1.Year)) { d += m.cost; } this.newcost = (part.nowcost); this.old_cost = (d - part.nowcost); }
public async Task Creat_card(card_kanoni card_kanoni) { await Task.Run(() => { var card = Ico.getValue <db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro && c.year == Ico.getValue <Date>().GetNowDate().Id).OrderByDescending(c => c.num).ToList().FirstOrDefault(); var num = 1; if (card != null) { num = card.num + 1; } var d = DateTime.Now; var name = "بطاقة إلتزام محاسبي رقم " + num + " سنة " + d.Year; var car = new card() { date = d, id_prosess = card_kanoni.part.Id_Pro, num = Ico.getValue <db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro).LastOrDefault().num + 1, year = Ico.getValue <db>().GetUnivdb().years.ToList().LastOrDefault().Id , location = Ico.getValue <IO>().CREATE_F_mo7asabi(part.process.location) + "\\" + name }; var card_mo7sabi = new card_mo7sabi() { id_client = card_kanoni.id_client, id_part = card_kanoni.id_part, cost = Cost, oldCost = card_kanoni.part.process.NewCost, card = car, num = numm, visa = null, subject = subject }; Ico.getValue <db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_kanoni.part.Id_Pro).ToList().First().NewCost -= Cost; Ico.getValue <db>().GetUnivdb().parts.ToList().Where(p => p.Id == card_kanoni.id_part).ToList().First().mcost += Cost; Ico.getValue <db>().GetUnivdb().cards.Add(car); Ico.getValue <db>().GetUnivdb().card_mo7sabi.Add(card_mo7sabi); Ico.getValue <db>().savedb(); Card_mo7asabiExecl c7 = new Card_mo7asabiExecl(Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.card.date == d).FirstOrDefault()); c7.CreateCard(); con(); }); }
public Addmo7asabiVewModel(card_kanoni card_kanoni) { part = card_kanoni.part; this.namepro = card_kanoni.part.process.Name; this.cost = card_kanoni.cost; this.namepart = part.Name; this.client = card_kanoni.client.Name; // var carda = Ico.getValue<db>().GetUnivdb().years.Where(y => y.year1.Year == DateTime.Now.Year).ToList().FirstOrDefault().cards.ToList().Where(c => c.id_prosess == card_kanoni.part.Id_Pro) // .ToList().FirstOrDefault(); var carda = Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => (c.card.year == Ico.getValue <Date>().GetNowDate().Id) && c.id_part == card_kanoni.id_part) .ToList().OrderByDescending(c => c.num).ToList().FirstOrDefault(); //.card_mo7sabi.Where(c=>c.id_part== card_kanoni.id_part).OrderByDescending(c=>c.num).LastOrDefault(); numm = 1; if (carda != null) { numm = carda.num + 1; } var nums = (numm.ToString().Length == 1) ? "0" + numm.ToString() : numm.ToString(); this.subject = "الإلتزام المحاسبي رقم " + nums + " للعقد المتعلق بالعملية " + part.process.Name; savecommand = new Command(() => { if ((part.Cost - part.mcost) >= Cost) { acc(); Creat_card(card_kanoni); } else { MessageBox.Show("المبلغ أكبر من الرصيد المتاح"); } }); Cancelcommand = new Command(() => { con(); }); }
public AddpartViewModel(process process) { strcode = process.Code; stpro = process.Name; var d = 0d; foreach (var p in process.parts) { d += p.Cost; } costpro = String.Format("{0:0.00}", d); this.num = process.parts.Count + 1; types = new List <TypePart>(); types.Add(new TypePart(1)); types.Add(new TypePart(2)); types.Add(new TypePart(3)); types.Add(new TypePart(4)); types.Add(new TypePart(5)); types.Add(new TypePart(6)); types.Add(new TypePart(7)); types.Add(new TypePart(8)); types.Add(new TypePart(9)); types.Add(new TypePart(10)); save = new Command(async() => { erour = new List <string>(); if (name.ToString().Length == 0) { erour.Add("الرجاء كتابة إسم الحصة "); } string pattern = "[1-9]+"; Regex rgx = new Regex(pattern); if (!rgx.IsMatch(cost.ToString())) { erour.Add("الرجاء كتابة المبلغ "); } if (numtype == null) { erour.Add("الرجاء إختيار نوع الحصة "); } OpenSample4Dialog(); if (erour.Count == 0) { AcceptSample4Dialog(); await Task.Run(() => { var part = new part() { Name = name, Cost = cost, Id_Pro = process.Id, num_type = numtype.numType, num = num, }; Ico.getValue <db>().GetUnivdb().parts.Add(part); Ico.getValue <db>().savedb(); OpenSample4Dialog(); }); Ico.getValue <ContentApp>().back(); } else { Sample4Content = new Messagebox(erour, () => { CancelSample4Dialog(); }); } }); back = new Command(() => { Ico.getValue <ContentApp>().back(); }); }
public void inTilData(card_kanoni card_kanoni) { this.process = card_kanoni.card.process; this.part = new Part(card_kanoni.part); this.client = card_kanoni.client.Name; this.newcost = card_kanoni.part.process.NewCost; ItemMo7asabis = new ObservableCollection <ItemMo7asabi>(card_kanoni.part.card_mo7sabi.Select(c => new ItemMo7asabi(c) { action_edit = (t) => { Sample4Content = new Editmo7asabi(t, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); }, start = () => { AcceptSample4Dialog(); AcceptSample4Dialog(); }, end = CancelSample4Dialog, addtashira = (t) => { Sample4Content = new Addtashira_mo7asabi(t, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); this.inTilData(Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(N => N.id == card_kanoni.id).ToList().SingleOrDefault()); }, edittashiraaction = (t) => { Sample4Content = new Edittashira_mo7asabi(t, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); } })); addmo7asabi = new Command(() => { var card = Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.id_part == card_kanoni.id_part).ToList().FirstOrDefault(); if (card != null && card.card.year == Ico.getValue <Date>().GetPevDate()?.Id&& Ico.getValue <db>().GetUnivdb().card_sa7ab.ToList().Where(c => c.card.id_prosess == card_kanoni.card.id_prosess).ToList().ToList().Count != 0) { MessageBox.Show((card != null) + ""); MessageBox.Show((card.card.year == Ico.getValue <Date>().GetPevDate()?.Id) + ""); MessageBox.Show((Ico.getValue <db>().GetUnivdb().card_sa7ab.ToList().Where(c => c.card.id_prosess == card_kanoni.card.id_prosess).ToList().ToList().Count != 0) + ""); MessageBox.Show(" الرجاء التأكد من إستخراج بظاقة سحب إلتزام مسبقاا "); } else { Sample4Content = new Addmo7asabi(card_kanoni, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); } }); }
public AddpartCardViewModel(part part, Action accept, Action Cancel) { this.namepart = part.Name; this.cost = part.Cost; this.nameprocess = part.process.Name; this.part = part; clients = Ico.getValue <db>().GetUnivdb().clients.ToList(); savecommand = new Command(() => { accept(); Task.Run(() => { var cardn = Ico.getValue <db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == part.Id_Pro && c.year == Ico.getValue <Date>().GetNowDate().Id).OrderByDescending(c => c.num).ToList().FirstOrDefault(); var num = 1; if (cardn != null) { num = cardn.num + 1; } var d = DateTime.Now; var name = "بطاقة إلتزام قانوني رقم " + num + " سنة " + d.Year; var card = new card() { id_prosess = part.process.Id, year = Ico.getValue <db>().GetUnivdb().years.ToList().LastOrDefault().Id, num = num, location = Ico.getValue <IO>().CREATE_F_kanoni(part.process.location) + "\\" + name, date = DateTime.Now, }; var kanoni = new card_kanoni() { card = card, id_client = client.Id, id_part = part.Id, cost = part.Cost, visa = null }; Ico.getValue <db>().GetUnivdb().cards.Add(card); Ico.getValue <db>().GetUnivdb().card_kanoni.Add(kanoni); Ico.getValue <db>().savedb(); Card_kanoniExecl card_Kanoni = new Card_kanoniExecl(Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(c => c.id_part == part.Id).ToList().FirstOrDefault()); card_Kanoni.CreateCard(); Cancel(); }); }); Cancelcommand = new Command(() => { Cancel(); }); addclient = new Command(() => { Ico.getValue <ContentApp>().page = new AddClient(); }); }
public void inTilData( ) { this.actionUP(); this.card = val.card; this.visa = val.visa; visibility = Visibility.Visible; tashiravis = Visibility.Visible; edittashiravis = Visibility.Collapsed; if (val.visa != null) { visibility = Visibility.Collapsed; edittashiravis = Visibility.Visible; tashiravis = Visibility.Collapsed; visa = val.visa; } tashira = new Command(() => { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new YesOrNo(" إذا أضفت التأشيرة لن تستطيع تعديل على بيانات العملية , الرجاء والتأكد قبل ذالك ", () => { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Addtashira_7isabi(val, inTilData); }, Ico.getValue <ContentApp>().CancelSample4Dialog); }); edittashira = new Command(() => { Ico.getValue <ContentApp>().Sample4Content = new Edittashira_7isabi(val, Ico.getValue <ContentApp>().AcceptSample4Dialog, Ico.getValue <ContentApp>().CancelSample4Dialog); Ico.getValue <ContentApp>().OpenSample4Dialog(); }); open = new Command(async() => { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().AcceptSample4Dialog(); await Task.Run(() => { ExcelHlper.OpenFile(val.card.location); Ico.getValue <ContentApp>().CancelSample4Dialog(); }); }); print = new Command(async() => { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().AcceptSample4Dialog(); await Task.Run(() => { ExcelHlper.PrintFile(val.card.location); Ico.getValue <ContentApp>().CancelSample4Dialog(); }); }); }
public ItemDafa3(card_dafa3 card_dafa3) { this.Cost = card_dafa3.Cost; this.num = card_dafa3.num; this.date = card_dafa3.date; this.alCost = card_dafa3.alcost; visibility = Visibility.Visible; tswiyavis = Visibility.Visible; edittswiyavis = Visibility.Collapsed; if (card_dafa3.tswiya != null) { visibility = Visibility.Collapsed; edittswiyavis = Visibility.Visible; tswiyavis = Visibility.Collapsed; } remove = new Command(() => { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(c => c.Id == card_dafa3.id_part).ToList().SingleOrDefault().nowcost -= Cost; Ico.getValue <db>().GetUnivdb().card_dafa3.Remove(Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.Id == card_dafa3.Id).FirstOrDefault()); Ico.getValue <db>().savedb(); // var cardm = Ico.getValue<db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.Id == mo7asbi.Id).SingleOrDefault(); // Ico.getValue<ContentApp>().SetPage(new Viewdafa3(cardm)); action(Cost); }); edit = new Command(() => { action_edit(card_dafa3); }); tswiya = new Command(() => { bool can = true; foreach (var c in Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.id_part == card_dafa3.id_part && c.date < card_dafa3.date)) { if (c.tswiya == null) { can = false; break; } } if (can) { addtswiya(card_dafa3); } else { MessageBox.Show("هنالك بطاقة ليست لها تأشيرة قبل هذه البطاقة "); } }); edittswiya = new Command(() => { edittswiyaaction(card_dafa3); }); open = new Command(() => { Card_dafa3Execl Card_dafa3Execl = new Card_dafa3Execl(card_dafa3); Card_dafa3Execl.CreateCard(); }); add_Mo7asabi = new Command(() => { // Ico.getValue<ContentApp>().page = new AddPartCard(part); // action_Mo7asabi(); }); }
public ItemDafa3(card_dafa3 card_dafa3) { this.Cost = card_dafa3.Cost; this.num = card_dafa3.num; this.date = card_dafa3.date; this.alCost = card_dafa3.alcost; visibility = Visibility.Visible; tswiyavis = Visibility.Visible; edittswiyavis = Visibility.Collapsed; if (card_dafa3.tswiya != null) { visibility = Visibility.Collapsed; edittswiyavis = Visibility.Visible; tswiyavis = Visibility.Collapsed; } remove = new Command(() => { // var cardm = Ico.getValue<db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.Id == mo7asbi.Id).SingleOrDefault(); // Ico.getValue<ContentApp>().SetPage(new Viewdafa3(cardm)); action(Cost); }); edit = new Command(() => { action_edit(card_dafa3); }); tswiya = new Command(() => { bool can = true; foreach (var c in Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.id_part == card_dafa3.id_part && c.date < card_dafa3.date)) { if (c.tswiya == null) { can = false; break; } } if (can) { addtswiya(card_dafa3); } else { MessageBox.Show("هنالك بطاقة ليست لها تأشيرة قبل هذه البطاقة "); } }); edittswiya = new Command(() => { edittswiyaaction(card_dafa3); }); open = new Command(async() => { ViewMo7sabiViewModel.Sample4Contentviw(new Progressbar()); await Task.Run(() => { ExcelHlper.OpenFile(card_mo7sabi.card.location); end(); }); }); print = new Command(async() => { ViewMo7sabiViewModel.Sample4Contentviw(new Progressbar()); await Task.Run(() => { ExcelHlper.PrintFile(card_mo7sabi.card.location); end(); }); }); }
private void CancelSample4Dialog() { IsSample4DialogOpen = false; this.inTilData(Ico.getValue <db>().GetUnivdb().card_7isab.ToList().Where(N => N.id_card == card.Id).ToList().SingleOrDefault()); }
public async Task Creat_card(part part) { await Task.Run(() => { var cardn = Ico.getValue <db>().GetUnivdb().cards.ToList().Where(c => c.id_prosess == part.Id_Pro && c.year == Ico.getValue <Date>().GetNowDate().Id).OrderByDescending(c => c.num).ToList().FirstOrDefault(); var num = 1; if (cardn != null) { num = cardn.num + 1; } var d = DateTime.Now; var name = "بطاقة إلتزام قانوني رقم " + num + " سنة " + d.Year; var card = new card() { id_prosess = part.process.Id, year = Ico.getValue <Date>().GetNowDate().Id, num = num, location = Ico.getValue <IO>().CREATE_F_kanoni(part.process.location) + "\\" + name, date = DateTime.Now, }; var kanoni = new card_kanoni() { card = card, id_client = client.Id, id_part = part.Id, cost = part.Cost, visa = null }; Ico.getValue <db>().GetUnivdb().cards.Add(card); Ico.getValue <db>().GetUnivdb().card_kanoni.Add(kanoni); Ico.getValue <db>().savedb(); Card_kanoniExecl card_Kanoni = new Card_kanoniExecl(Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(c => c.id_part == part.Id).ToList().FirstOrDefault()); card_Kanoni.CreateCard(); Cancel(); }); }
public AddpartViewModel(process process ) { this.process = process; this.num = process.parts.Count+1; types = new List<TypePart>(); types.Add(new TypePart(1)); types.Add(new TypePart(2)); types.Add(new TypePart(3)); types.Add(new TypePart(4)); types.Add(new TypePart(5)); types.Add(new TypePart(6)); types.Add(new TypePart(7)); types.Add(new TypePart(8)); types.Add(new TypePart(9)); types.Add(new TypePart(10)); save = new Command(()=> { if (name.ToString().Length == 0) { erour.Add("الرجاء كتابة إسم العملية "); } if (cost.ToString().Length == 0) { erour.Add("الرجاء كتابة المبلغ "); } if (alhcost.ToString().Length == 0) { erour.Add("الرجاء كتابة رقم الثابت للعملية "); } if (numtype.numType == 0) { erour.Add("الرجاء كتابة رقم الثابت للعملية "); } if (erour.Count == 0) { var part = new part() { Name = name, Cost = cost, Id_Pro = process.Id, num_type = numtype.numType, num = num, alpart = alhcost }; Ico.getValue<db>().GetUnivdb().parts.Add(part); Ico.getValue<db>().GetUnivdb().SaveChanges(); Ico.getValue<ContentApp>().back(); } else { } }); back = new Command(()=> { Ico.getValue<ContentApp>().back(); }); }
public processesViewModel() { actionUP = () => { this.processes = new ObservableCollection <processesViewMODEL>(Ico.getValue <db>().GetUnivdb().processes.ToList().Select(p => new processesViewMODEL(p) { removeaction = () => { OpenSample4Dialog(); Sample4Content = new YesOrNo("هل أنت مـتأكد من قيامك بحذف هذه العملية ؟ , لا يمكن التراجع عن هذه الحذف ", async() => { AcceptSample4Dialog(); await Task.Run(() => { var ps = Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pro => pro.Id == p.Id).ToList().FirstOrDefault(); foreach (var i in ps.cards.ToList()) { Ico.getValue <db>().GetUnivdb().card_7isab.AddRange(i.card_7isab); } foreach (var i in ps.cards.ToList()) { Ico.getValue <db>().GetUnivdb().card_kanoni.AddRange(i.card_kanoni); } foreach (var i in ps.cards.ToList()) { Ico.getValue <db>().GetUnivdb().card_mo7sabi.AddRange(i.card_mo7sabi); } foreach (var i in ps.cards.ToList()) { Ico.getValue <db>().GetUnivdb().card_dafa3.AddRange(i.card_dafa3); } Ico.getValue <db>().GetUnivdb().processes.Remove(Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pro => pro.Id == p.Id).ToList().FirstOrDefault()); Ico.getValue <db>().savedb(); CancelSample4Dialog(); inTilData(); }); }, () => { CancelSample4Dialog(); }); } })); }; inTilData(); Count = processes.Count; Serech = new CommandPar((t) => { var text = (string)t; processes = new ObservableCollection <processesViewMODEL>(Ico.getValue <db>().GetUnivdb().processes.ToList().Select(p => new processesViewMODEL(p) { removeaction = () => { OpenSample4Dialog(); Sample4Content = new YesOrNo("هل أنت مـنأكد من قيامك بحذف هذه العملية ؟ , لا يمكن التراجع عن هذه الحذف ", async() => { AcceptSample4Dialog(); await Task.Run(() => { Ico.getValue <db>().GetUnivdb().processes.Remove(Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pro => pro.Id == p.Id).ToList().FirstOrDefault()); Ico.getValue <db>().savedb(); CancelSample4Dialog(); inTilData(); }); }, () => { CancelSample4Dialog(); }); } } ).Where((l) => l.Code.Contains(text) || l.Name.Contains(text)) ); }); new_ = new Command(() => { // MainViewModel.page = new NewProcesses(); Ico.getValue <ContentApp>().page = new NewProcesses(); }); }
public ItemPart(part part) { this.Name = part.Name; this.Cost = part.Cost; this.num = part.num; var lc = part.process.cards; if (lc.ToList().Count > 0) { var a = lc.ToList().Where(c => c.card_7isab.Count > 0).FirstOrDefault(); if (a != null) { if (a.card_7isab?.ToList().FirstOrDefault() != null && a.card_7isab?.ToList().FirstOrDefault().visa != null) { visibility = Visibility.Collapsed; } } } remove = new Command(() => { action(this); }); edit = new Command(() => { var prr = Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == part.Id).FirstOrDefault(); MessageBox.Show(prr.card_mo7sabi.ToList().Count + ""); MessageBox.Show(prr.card_dafa3.ToList().Count + ""); if (prr.card_mo7sabi.ToList().Count == 0 && prr.card_dafa3.ToList().Count == 0) { Ico.getValue <ContentApp>().page = new EditPart(part); } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الحصة تحتوي على مجموعه من البطاقات الرجاء حذفها وإعد المحاولة .. " }, Ico.getValue <ContentApp>().CancelSample4Dialog); } }); view = new Command(() => { Ico.getValue <ContentApp>().page = new ViewPart(part); }); add_Mo7asabi = new Command(() => { if (part.process.edit == false) { var card = Ico.getValue <db>().GetUnivdb().card_kanoni.ToList().Where(c => c.part.Id == part.Id).FirstOrDefault(); if (card != null) { Ico.getValue <ContentApp>().page = new ViewMo7sabi(card); } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء إستخرج بطاقة إلتزام قانوني مسبقااا" }, Ico.getValue <ContentApp>().CancelSample4Dialog); } } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء إستخرج بطاقة أخذ بحساب مسبقااا" }, Ico.getValue <ContentApp>().CancelSample4Dialog); } }); add_kanoni = new Command(() => { if (part.process.edit == false) { action_kanoni(); } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء إستخرج بطاقة أخذ بحساب مسبقااا" }, Ico.getValue <ContentApp>().CancelSample4Dialog); } }); dafa3action = new Command(() => { if (part.process.edit == false) { var card = Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.id_part == part.Id).FirstOrDefault(); if (card != null) { Ico.getValue <ContentApp>().page = new Viewdafa3(card.part); } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء إستخرج بطاقة إلتزام محاسبي مسبقااا" }, Ico.getValue <ContentApp>().CancelSample4Dialog); } } else { Ico.getValue <ContentApp>().OpenSample4Dialog(); Ico.getValue <ContentApp>().Sample4Content = new Messagebox(new List <string> { "الرجاء إستخرج بطاقة أخذ بحساب مسبقااا" }, Ico.getValue <ContentApp>().CancelSample4Dialog); } }); }
public async Task Creat_card(part part) { await Task.Run(() => { var card = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.id_part == part.Id && c.id_year == Ico.getValue <Date>().GetNowDate().Id).OrderByDescending(c => c.num).ToList().FirstOrDefault(); var num = 1; if (card != null) { num = card.num + 1; } var d = DateTime.Now; var name = "بطاقة دفع رقم " + num + " سنة " + d.Year; var card_dafa3 = new card_dafa3() { date = d, num = num, id_part = part.Id, Cost = Cost, alcost = AlCost, location = Ico.getValue <IO>().CREATE_F_dafa3(part.process.location) + "\\" + name, id_year = Ico.getValue <Date>().GetNowDate().Id, tswiya = null }; Ico.getValue <db>().GetUnivdb().parts.ToList().Where(c => c.Id == part.Id).SingleOrDefault().nowcost += Cost; // Ico.getValue<db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_kanoni.part.Id_Pro).ToList().First().parts.ToList().Where(p => p.Id == card_kanoni.id_part).ToList().First().nowcost += Cost; Ico.getValue <db>().GetUnivdb().card_dafa3.Add(card_dafa3); Ico.getValue <db>().savedb(); Card_dafa3Execl c7 = new Card_dafa3Execl(Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.num == num && c.id_year == Ico.getValue <Date>().GetNowDate().Id).FirstOrDefault()); c7.CreateCard(); con(); }); }
public ViewAccountViewModel() { this.actionUP = () => { val = Ico.getValue <db>().GetUnivdb().users.ToList().Where(c => c.id == Ico.getValue <user>().id).ToList().FirstOrDefault(); }; inTilData(); name = val.name; username = val.username; date_gust = val.date_gust.GetDateTimeFormats()[0]; date_edit = val.date_edit.GetDateTimeFormats()[0]; edit = new Command(() => { Ico.getValue <ContentApp>().page = new EditAccount(val); }); }
public void inTilData() { this.UpDate(); this.process = val.card.process; this.part = new Part(val.part); this.client = val.client.Name; this.newcost = val.part.process.NewCost; ItemMo7asabis = new ObservableCollection <ItemMo7asabi>(val.part.card_mo7sabi.Select(card_mo7sabi => new ItemMo7asabi(card_mo7sabi) { action_edit = (t) => { Sample4Content = new Editmo7asabi(t, AcceptSample4Dialog, CancelSample4Dialog); OpenSample4Dialog(); }, start = () => { OpenSample4Dialog(); Sample4Content = new YesOrNo("هل أنت متأكد من قيامك بحذف هذه البطاقة من الحصة ,لا يمكن التراجع عن الحذف", async() => { AcceptSample4Dialog(); await Task.Run(() => { Ico.getValue <db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_mo7sabi.part.Id_Pro).ToList().SingleOrDefault().NewCost += card_mo7sabi.cost; Ico.getValue <db>().changedNumCard(card_mo7sabi.card); Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(card_mo7sabi)); IEnumerable <card_dafa3> get_data(card_mo7sabi card) { var cs = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => (c.id_part == card_mo7sabi.id_part) && (c.tswiya == null) && (c.date > card_mo7sabi.card.date)); foreach (var c in cs) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(p => p.Id == card_mo7sabi.id_part).First().nowcost -= c.Cost; } return(cs); } foreach (var c in Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.part.Id_Pro == Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().id_prosess&& c.card.date > Ico.getValue <db>().GetUnivdb().cards. ToList().Where(cl => cl.Id == card_mo7sabi.id_card).ToList().SingleOrDefault().date)) { Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(ca => ca.Id == c.Id).ToList().FirstOrDefault().oldCost += card_mo7sabi.cost; Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(ca => ca.Id == c.Id).ToList().FirstOrDefault().num -= 1; } Ico.getValue <db>().GetUnivdb().card_mo7sabi.Remove(Ico.getValue <db>().GetUnivdb().card_mo7sabi. ToList().Where(c => c.Id == card_mo7sabi.Id).ToList().SingleOrDefault()); Ico.getValue <db>().GetUnivdb().cards.Remove(Ico.getValue <db>().GetUnivdb().cards. ToList().Where(c => c.Id == card_mo7sabi.id_card).ToList().SingleOrDefault()); Ico.getValue <db>().savedb(); CancelSample4Dialog(); }); }, () => { CancelSample4Dialog(); }); },
public Addsa7abiVewModel(process process) { List <p_sa7ab> ps = new List <p_sa7ab>(); // this.date = Ico.getValue<Date>().GetPevDate().year1.Year + "/12/31"; Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(process)); IEnumerable <card_dafa3> get_data(process p) { var cs = Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.part.Id_Pro == p.Id && c.tswiya == null).ToList(); foreach (var c in cs) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == c.id_part).First().nowcost -= c.Cost; } Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(cs); return(cs); } foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { foreach (var m in p.card_mo7sabi.ToList().Where(c => c.visa == null).ToList()) { Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pr => pr.Id == process.Id).ToList().First().NewCost += m.cost; Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == m.id_part).First().mcost -= m.cost; Ico.getValue <db>().GetUnivdb().card_mo7sabi.Remove(Ico.getValue <db>().GetUnivdb().card_mo7sabi. ToList().Where(c => c.Id == m.Id).ToList().SingleOrDefault()); Ico.getValue <db>().GetUnivdb().cards.Remove(Ico.getValue <db>().GetUnivdb().cards. ToList().Where(c => c.Id == m.id_card).ToList().SingleOrDefault()); } /// this.sa7abCost+= Ico.getValue<db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().mcost-= Ico.getValue<db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().nowcost; } var dn = 0.0; foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { var d = p.mcost - p.nowcost; if (d != 0) { ps.Add(new p_sa7ab() { id_part = p.Id, cost = d, }); dn += d; } } Ico.getValue <db>().savedb(); this.sa7abCost = dn; this.namepro = process.Name; this.Cost = Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pr => pr.Id == process.Id).ToList().First().NewCost; savecommand = new Command(() => { if (sa7abCost != 0) { var car = new card() { date = DateTime.Now, id_prosess = process.Id, num = 1, year = Ico.getValue <db>().GetUnivdb().years.ToList().LastOrDefault().Id, location = "" }; var card_sa7ab = new card_sa7ab() { cost = sa7abCost, card = car, visa = null, old_cost = Cost }; Ico.getValue <db>().GetUnivdb().cards.Add(car); Ico.getValue <db>().GetUnivdb().card_sa7ab.Add(card_sa7ab); Ico.getValue <db>().GetUnivdb().processes.ToList().Where(pr => pr.Id == process.Id).ToList().First().NewCost += sa7abCost; foreach (var p in Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id_Pro == pr.Id_Pro).ToList()) { Ico.getValue <db>().GetUnivdb().parts.ToList().Where(pr => pr.Id == p.Id).First().mcost = p.nowcost; } Ico.getValue <db>().savedb(); var i = Ico.getValue <db>().GetUnivdb().card_sa7ab.ToList().Where(c => c.card.year == Ico.getValue <Date>().GetNowDate().Id).FirstOrDefault().id; foreach (p_sa7ab p in ps) { p.id_sa7ab = i; } Ico.getValue <db>().GetUnivdb().p_sa7ab.AddRange(ps); Ico.getValue <db>().savedb(); } else { MessageBox.Show("لا تستطيع إستخراج بطاقة سحب لأن المبلغ = 0 دج"); } con(); }); Cancelcommand = new Command(() => { con(); }); }