public Addtashira_mo7asabi_VewModel(card_mo7sabi card_mo7sabi)
 {
     this.num    = card_mo7sabi.num.ToString();
     this.part   = card_mo7sabi.part.Name;
     this.cost   = String.Format("{0:0.00}", card_mo7sabi.cost);
     savecommand = 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)
         {
             acc();
             Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(d => d.Id == card_mo7sabi.Id).ToList().FirstOrDefault().visa = visa;
             Ico.getValue <db>().savedb();
             con();
         }
         else
         {
             MessageBox.Show("هنالك بطاقة ليست لها تأشيرة قبل هذه البطاقة ");
         }
     });
 }
Beispiel #2
0
 public Editmo7asabi(card_mo7sabi card_mo7sabi, Action accept)
 {
     InitializeComponent();
     this.DataContext = new Editmo7asabiVewModel(card_mo7sabi)
     {
         acc = accept,
     };
 }
Beispiel #3
0
 public partsMo7asabiModel(card_mo7sabi card_mo7sabi)
 {
     this.NamePart = card_mo7sabi.part.Name;
     this.Num      = card_mo7sabi.card.num;
     this.DateTime = card_mo7sabi.card.date;
     this.OldCost  = card_mo7sabi.part.Cost;
     MessageBox.Show((card_mo7sabi.part.Cost - card_mo7sabi.cost) + "");
     this.NewCost = card_mo7sabi.part.Cost - card_mo7sabi.cost;
 }
Beispiel #4
0
 public Addtashira_sa7ab(card_mo7sabi card_mo7sabi, Action accept, Action Cancel)
 {
     InitializeComponent();
     this.DataContext = new Addtashira_mo7asabi_VewModel(card_mo7sabi)
     {
         acc = accept,
         con = Cancel
     };
 }
        public Editmo7asabiVewModel(card_mo7sabi card_mo7sabi)
        {
            part          = card_mo7sabi.part;
            this.namepro  = card_mo7sabi.part.process.Name;
            this.cost     = card_mo7sabi.cost;
            this.namepart = part.Name;
            var client = card_mo7sabi.client;

            this.nameclient     = client.Name;
            this.codebankclient = client.num_account;
            this.bankclient     = client.bank;
            this.Cost           = card_mo7sabi.cost;
            savecommand         = new Command(() =>
            {
                var d = 0d;
                foreach (var c in part.card_dafa3.ToList().Where(c => c.num < card_mo7sabi.num))
                {
                    d += c.Cost;
                }
                if ((part.Cost - d) > Cost)
                {
                    acc();
                    Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.Id == card_mo7sabi.Id).SingleOrDefault().cost = Cost;
                    //                Ico.getValue<db>().GetUnivdb().parts.ToList().Where(p => p.Id == card_mo7sabi.id_part).First().nowcost -= (card_mo7sabi.cost - Cost);
                    //           Ico.getValue<db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_mo7sabi.part.Id_Pro).First().parts.ToList().Where(p => p.Id == card_mo7sabi.id_part).First().nowcost -= (card_mo7sabi.cost - Cost);
                    Ico.getValue <db>().GetUnivdb().processes.ToList().Where(p => p.Id == card_mo7sabi.part.Id_Pro).First().NewCost += (card_mo7sabi.cost - Cost);
                    Ico.getValue <db>().GetUnivdb().card_dafa3.RemoveRange(get_data(card_mo7sabi));
                    Ico.getValue <db>().savedb();
                    con();
                }
                else
                {
                    MessageBox.Show("المبلغ أكبر من الرصيد المتاح");
                }
            });


            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);
            }

            Cancelcommand = new Command(() => {
                con();
            });
        }
Beispiel #6
0
 public Addtashira_mo7asabi_VewModel(card_mo7sabi card_mo7sabi)
 {
     this.num    = card_mo7sabi.num.ToString();
     this.part   = card_mo7sabi.part.Name;
     this.cost   = String.Format("{0:0.00}", card_mo7sabi.cost);
     savecommand = new Command(() =>
     {
         acc();
         Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(d => d.Id == card_mo7sabi.Id).ToList().FirstOrDefault().visa = visa;
         Ico.getValue <db>().savedb();
         con();
     });
 }
Beispiel #7
0
        public async Task Creat_card(card_kanoni card_kanoni)
        {
            MessageBox.Show(card_kanoni.part.Id_Pro + "");
            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 <Date>().GetNowDate().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.num == num && c.card.year == Ico.getValue <Date>().GetNowDate().Id).FirstOrDefault());
                c7.CreateCard();

                con();
            });
        }
Beispiel #8
0
        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(() => {
                addtashira(card_mo7sabi);
            });
            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);
                }
                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());
                foreach (var c in Ico.getValue <db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.num > card_mo7sabi.num))
                {
                    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>().savedb();
                end();
            });
            add_Mo7asabi = new Command(() => {
                //                Ico.getValue<ContentApp>().page = new AddPartCard(part);

                //         action_Mo7asabi();
            });
        }
        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();

            var 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();

                    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       = 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 = 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();

                    con();
                }
                else
                {
                    MessageBox.Show("المبلغ أكبر من الرصيد المتاح");
                }
            });
            Cancelcommand = new Command(() => {
                con();
            });
        }
Beispiel #10
0
 public Card_mo7asabiExecl(card_mo7sabi card_mo7sabi)
 {
     this.card_mo7sabi = card_mo7sabi;
 }