예제 #1
0
        public Adddafa3VewModel(part part)
        {
            this.part = part;

            this.namepro  = part.process.Name;
            this.cost     = cost;
            this.namepart = part.Name;

            var client = part.card_kanoni.ToList().FirstOrDefault().client;

            this.nameclient     = client.Name;
            this.codebankclient = client.num_account;
            this.bankclient     = client.bank;


            savecommand = new Command(() =>
            {
                erour = new List <string>();


                string pattern = "[0-9]+";
                Regex rgx      = new Regex(pattern);
                if (Cost == 0 || !rgx.IsMatch(cost.ToString()))
                {
                    erour.Add("الرجاء كتابة المبلغ ");
                }
                else
                {
                    if (!((part.mcost - part.nowcost) >= Cost))
                    {
                        erour.Add("المبلغ أكبر من الرصيد المتاح");
                    }
                }



                if (AlCost.ToString().Length == 0)
                {
                    erour.Add("الرجاء كتابة  المبلغ حرفيا   ");
                }
                if (erour.Count == 0)
                {
                    acc();
                    Sample4Content = new Messagebox(erour, con);
                }
                else
                {
                    Creat_card(part);
                }
                //              var cardm = Ico.getValue<db>().GetUnivdb().card_mo7sabi.ToList().Where(c => c.Id == card_mo7sabi.Id).SingleOrDefault();
                //    Ico.gtValue<ContentApp>().SetPage(new Viewdafa3(cardm));
            });
            Cancelcommand = new Command(() =>
            {
                con();
            });
        }
        public Editdafa3VewModel(card_dafa3 card_dafa3)
        {
            part          = card_dafa3.part;
            this.namepro  = card_dafa3.part.process.Name;
            this.cost     = card_dafa3.part.Cost;
            this.namepart = part.Name;
            var client = card_dafa3.part.card_kanoni.ToList().FirstOrDefault().client;

            this.nameclient     = client.Name;
            this.codebankclient = client.num_account;
            this.bankclient     = client.bank;
            this.Costd          = card_dafa3.Cost;
            this.AlCost         = card_dafa3.alcost;
            this.tswiya         = card_dafa3.tswiya;
            savecommand         = new Command(() =>
            {
                if (Costd != card_dafa3.Cost || AlCost != card_dafa3.alcost || tswiya != card_dafa3.tswiya)
                {
                    erour = new List <string>();


                    string pattern = "[0-9]+";
                    Regex rgx      = new Regex(pattern);
                    if (Costd == 0 || !rgx.IsMatch(cost.ToString()))
                    {
                        erour.Add("الرجاء كتابة المبلغ ");
                    }
                    else
                    {
                        if (!((part.mcost - part.nowcost + card_dafa3.Cost) >= Costd))
                        {
                            erour.Add("المبلغ أكبر من الرصيد المتاح");
                        }
                    }



                    if (AlCost.ToString().Length == 0)
                    {
                        erour.Add("الرجاء كتابة  المبلغ حرفيا   ");
                    }
                    if (tswiya.ToString().Length == 0)
                    {
                        erour.Add("الرجاء كتابة   تسوية الفاتوؤة   ");
                    }
                    Ico.getValue <ContentApp>().OpenSample4Dialog();
                    if (erour.Count != 0)
                    {
                        Ico.getValue <ContentApp>().Sample4Content = new Messagebox(erour, () =>
                        {
                            Ico.getValue <ContentApp>().Sample4Content = THIS;
                        });
                    }
                    else
                    {
                        var t = (card_dafa3.Cost - Costd);
                        Ico.getValue <ContentApp>().AcceptSample4Dialog();
                        Ico.getValue <db>().GetUnivdb().parts.ToList().Where(c => c.Id == card_dafa3.id_part).ToList().FirstOrDefault().nowcost -= t;
                        Ico.getValue <db>().GetUnivdb().parts.ToList().Where(c => c.Id == card_dafa3.id_part).ToList().FirstOrDefault().mcost   += t;
                        Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.Id == card_dafa3.Id).FirstOrDefault().Cost              = Costd;
                        Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.Id == card_dafa3.Id).FirstOrDefault().tswiya            = tswiya;
                        Ico.getValue <db>().GetUnivdb().card_dafa3.ToList().Where(c => c.Id == card_dafa3.Id).FirstOrDefault().alcost            = AlCost;
                        Ico.getValue <db>().savedb();
                        acc();
                        Ico.getValue <ContentApp>().CancelSample4Dialog();
                    }
                }
            });
            back = new Command(() => {
                Ico.getValue <ContentApp>().back();
            });

            Cancelcommand = new Command(() => {
                Ico.getValue <ContentApp>().CancelSample4Dialog();
            });
        }