Ejemplo n.º 1
0
        private void label18_Click(object sender, EventArgs e)
        {
            string shenasnameID = GlobalVariable.shenasnameID;

            using (var dbcontext = new Model.Context())
            {
                shenasname shen = dbcontext.shenasnames.SingleOrDefault(x => x.ID == shenasnameID);

                if (shen.final != 1)
                {
                    shen.comment = commentSection.Text;
                    //string parentID = shen.parent;

                    //List<shenasname> shenList = dbcontext.shenasnames.Where(x => x.parent == parentID).ToList();
                    //foreach (shenasname item in shenList)
                    //{
                    //    item.master = "0";
                    //};
                    //shen.isDone = true;
                    //shen.master = "1";
                    //shen.final = 1;
                    dbcontext.SaveChanges();
                }
                //GlobalVariable.shenasnameID = shen.parent;
            }
            this.Hide();
            projectFiles pf = new projectFiles();

            pf.Show();
        }
Ejemplo n.º 2
0
        private void label7_Click(object sender, EventArgs e)
        {
            shenasnameFounder model = new shenasnameFounder()
            {
                fullname     = fullname.Text,
                semat        = semat.Text,
                shenasnameID = GlobalVariable.shenasnameID
            };

            dbcontext.shenasnameFounders.Add(model);
            dbcontext.SaveChanges();

            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form2_shenasnameAdd")
                {
                    break;
                }

                index += 1;
            }
            this.Hide();

            Application.OpenForms[index].Close();
            Form2_shenasnameAdd form2 = new Form2_shenasnameAdd();

            form2.Show();
        }
Ejemplo n.º 3
0
        private void label7_Click(object sender, EventArgs e)
        {
            Model.edari model = new Model.edari()
            {
                kollPD       = Int32.Parse(dollari.Text),
                kollPR       = Int32.Parse(rially.Text),
                title        = title.Text,
                shenasnameID = GlobalVariable.shenasnameID,
            };
            dbcontext.edaris.Add(model);
            dbcontext.SaveChanges();
            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form13_Hazine_edari")
                {
                    break;
                }

                index += 1;
            }
            this.Hide();

            Application.OpenForms[index].Close();
            Form13_Hazine_edari form13 = new Form13_Hazine_edari();

            form13.Show();
        }
Ejemplo n.º 4
0
        private void filter_Click(object sender, EventArgs e)
        {
            string bakhshID = GlobalVariable.bakhshID;

            using (var dbcontext = new Model.Context())
            {
                bakhsh bakh = dbcontext.bakhshes.SingleOrDefault(x => x.ID == bakhshID);

                if (bakh.final != 1)
                {
                    string parentID = bakh.parent;
                    bakh.title    = title.Text;
                    bakh.masoul   = masool.Text;
                    bakh.janeshin = janeshin.Text;


                    List <bakhsh> lst = dbcontext.bakhshes.Where(x => x.parent == parentID).ToList();
                    foreach (bakhsh item in lst)
                    {
                        item.master = "0";
                    }
                    ;
                    bakh.isDone = true;
                    bakh.master = "1";
                    bakh.final  = 1;
                    dbcontext.SaveChanges();
                }
                GlobalVariable.bakhshID = bakh.parent;
            }

            this.Hide();
            Bakhsh_List form5 = new Bakhsh_List();

            form5.Show();
        }
Ejemplo n.º 5
0
        private void label3_Click(object sender, EventArgs e)
        {
            string shenasnameID = GlobalVariable.shenasnameID;

            using (var dbcontext = new Model.Context())
            {
                shenasname shen = dbcontext.shenasnames.SingleOrDefault(x => x.ID == shenasnameID);

                if (shen.final != 1)
                {
                    string parentID = shen.parent;

                    List <shenasname> shenList = dbcontext.shenasnames.Where(x => x.parent == parentID).ToList();
                    foreach (shenasname item in shenList)
                    {
                        item.master = "0";
                    }
                    ;
                    shen.isDone = true;
                    shen.master = "1";
                    shen.final  = 1;

                    dbcontext.SaveChanges();
                }

                this.Hide();
                Form5_shenasnameList form5 = new Form5_shenasnameList();
                form5.Show();
            }
        }
Ejemplo n.º 6
0
        private void label16_Click(object sender, EventArgs e) // تایید
        {
            Model.shenasname item = dbcontext.shenasnames.Where(x => x.ID == GlobalVariable.shenasnameID).FirstOrDefault();
            if (item.final != 1)
            {
                try
                {
                    item.hadaf = hadaf.Text;
                    item.title = title.Text;

                    item.date         = DateTime.Now;
                    item.datePishbini = datePishbini.Text;
                    //item.dateFrom = "";//dateFrom.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
                    //item.dateTo = ""; //dateTo.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
                    item.markaz  = markazcombo.SelectedValue.ToString();
                    item.dastgah = dastgah.SelectedValue.ToString();
                    dbcontext.SaveChanges();
                }
                catch (Exception error)
                {
                    //throw;
                }
            }
            Form6_PMainMoney form6 = new Form6_PMainMoney();

            form6.Show();
            this.Hide();


            // this.Hide();
        }
Ejemplo n.º 7
0
        private void label7_Click(object sender, EventArgs e)
        {
            Model.sarmaye model = new Model.sarmaye()
            {
                count        = Int32.Parse(count.Text),
                creatoreCo   = Ctitle.Text,
                title        = title.Text,
                kollPD       = Int32.Parse(koldollary.Text),
                kollPR       = Int32.Parse(kolrially.Text),
                vahedPD      = Int32.Parse(vaheddollary.Text),
                vahedPR      = Int32.Parse(vahedrially.Text),
                shenasnameID = GlobalVariable.shenasnameID,
            };
            dbcontext.sarmayes.Add(model);
            dbcontext.SaveChanges();
            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form9_money_sarmaye")
                {
                    break;
                }

                index += 1;
            }
            this.Hide();

            Application.OpenForms[index].Close();
            Form9_money_sarmaye form9 = new Form9_money_sarmaye();

            form9.Show();
        }
Ejemplo n.º 8
0
        private void filter_Click(object sender, EventArgs e)
        {
            using (Model.Context dbcontext = new Model.Context())
            {
                user newUser = new user()
                {
                    //family_Number = family_Number.Text,
                    //grade = grade.Text,
                    //madrak = madrak.Text,
                    //madrak_Title = madrak.Text,
                    //maskan = maskan.Text,
                    //meli_Code = meli_Code.Text,
                    //mobile = mobile.Text,
                    name         = name.Text,
                    pasdari_Code = pasdari_Code.Text,
                    shomareHesab = shomareHesab.Text,
                    //phone = phone.Text,
                    sazman_Enterdate = DateTime.Now, // sazman_Enterdate.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime(),
                    Sepah_Enterdate  = DateTime.Now, //Sepah_Enterdate.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime(),
                    //tahol = tahol.Text,
                    //univercity = univercity.Text,
                    //univercity_Score = shomareHesab.Text,
                    //jaygah = jaygah.Text
                };
                dbcontext.users.Add(newUser);
                dbcontext.SaveChanges();

                DataTable dt       = new DataTable();
                User_List userList = new User_List(dt);
                userList.Show();
                this.Hide();
            }
        }
Ejemplo n.º 9
0
        private void DeleteItem(object sender, EventArgs e)
        {
            try
            {
                var    element = sender as Label;
                string id      = element.Name.Substring(1, element.Name.Length - 1);
                GlobalVariable.markazID = id;



                List <markaz> markazlist = dbcontext.markazs.Where(x => x.BakhshID == id).ToList();
                if (markazlist.Count == 0)
                {
                    markaz delitem = dbcontext.markazs.SingleOrDefault(x => x.ID == GlobalVariable.markazID);
                    dbcontext.markazs.Remove(delitem);
                    dbcontext.SaveChanges();
                    Markaz_List form2 = new Markaz_List();
                    this.Hide();
                    //form2.Show();
                }
            }
            catch (Exception errror)
            {
                message.Text = errror.InnerException.Message;
            }
        }
Ejemplo n.º 10
0
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            using (var dbcontext = new Model.Context())
            {
                int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex;
                if (iSelectedGridIndex != 0)
                {
                    return;
                }
                int rowindex = dataGridView1.CurrentCell.RowIndex;
                int rowID    = Int32.Parse(dataGridView1.Rows[rowindex].Cells[2].Value.ToString());

                Model.archive model = dbcontext.Archives.SingleOrDefault(x => x.ID == rowID);

                dbcontext.Entry(model).State = EntityState.Deleted;
                dbcontext.SaveChanges();



                List <Model.archive> lst = (from p in dbcontext.Archives
                                            where p.hesab == "1"
                                            select p).ToList();
                dataGridView1.DataSource = lst;
                string imageName = model.imageName;
                var    directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);


                System.IO.File.Delete(directory + imageName);
            }
        }
Ejemplo n.º 11
0
        private void filter_Click(object sender, EventArgs e)
        {
            using (Model.Context dbcontext = new Model.Context())
            {
                bank newBank = new bank()
                {
                    number = shomareHesab.Text,
                    title  = name.Text,
                    type   = bankType.SelectedItem.ToString(),
                };
                dbcontext.banks.Add(newBank);
                dbcontext.SaveChanges();

                DataTable dt       = new DataTable();
                Bank_List userList = new Bank_List(dt);
                userList.Show();
                this.Hide();
            }
        }
Ejemplo n.º 12
0
        private void label7_Click(object sender, EventArgs e)
        {
            string gam = gamasli.Text;
            string onv = onvan.Text;
            string shr = sharh.Text;
            string mod = modat.Text;
            string dar = darsad.Text;
            string das = dastavard.Text;

            shenasnameGam model = new shenasnameGam()
            {
                achivement   = dastavard.Text,
                darsadeVazni = Int32.Parse(darsad.Text),
                description  = sharh.Text,
                duration     = modat.Text,
                title        = onvan.Text,
                shenasnameID = GlobalVariable.shenasnameID,
                gamAsli      = gamasli.Text,
            };

            dbcontext.shenasnameGams.Add(model);
            dbcontext.SaveChanges();

            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form2_shenasnameAdd")
                {
                    break;
                }

                index += 1;
            }

            this.Hide();

            Application.OpenForms[index].Close();
            Form2_shenasnameAdd form2 = new Form2_shenasnameAdd();

            form2.Show();
        }
Ejemplo n.º 13
0
        private void label7_Click(object sender, EventArgs e)
        {
            mostaan.Model.sayer model = new Model.sayer()
            {
                count        = Int32.Parse(count.Text),
                creatoreCo   = Ctitle.Text,
                title        = title.Text,
                kollPD       = Int32.Parse(koldollary.Text),
                kollPR       = Int32.Parse(kolrially.Text),
                vahedPD      = Int32.Parse(vaheddollary.Text),
                vahedPR      = Int32.Parse(vahedrially.Text),
                shenasnameID = GlobalVariable.shenasnameID,
            };
            Model.sayer item = dbcontext.sayers.SingleOrDefault(x => x.title == title.Text && x.shenasnameID == GlobalVariable.shenasnameID);
            if (item == null)
            {
                dbcontext.sayers.Add(model);
                dbcontext.SaveChanges();
                int indexx = 0;
                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "Form19_saryer")
                    {
                        break;
                    }

                    indexx += 1;
                }
                this.Hide();

                Application.OpenForms[indexx].Close();
                Form19_saryer form11 = new Form19_saryer();
                form11.Show();
            }
            else
            {
                message.Text = "عنوان تکراری مجاز نیست";
            }
        }
Ejemplo n.º 14
0
        private void dataGridView1_CellContentDoubleClick_1(object sender, DataGridViewCellEventArgs e)
        {
            using (var dbcontext = new Model.Context())
            {
                Model.shenasname item = dbcontext.shenasnames.Where(x => x.ID == GlobalVariable.shenasnameID).FirstOrDefault();
                if (item.final != 1)
                {
                    int iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex;
                    if (iSelectedGridIndex != 0)
                    {
                        return;
                    }
                    int    rowindex = dataGridView1.CurrentCell.RowIndex;
                    string rowID    = dataGridView1.Rows[rowindex].Cells[2].Value.ToString();

                    Model.ejraeiat model = dbcontext.ejraeiats.SingleOrDefault(x => x.title == rowID);
                    dbcontext.Entry(model).State = EntityState.Deleted;
                    dbcontext.SaveChanges();
                    int index = 0;
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.Name == "Form6-Money-Ejraeiat")
                        {
                            break;
                        }
                        else
                        {
                            index += 1;
                        }
                    }
                    this.Hide();

                    Application.OpenForms[index - 1].Close();
                    Form6_PMainMoney form6 = new Form6_PMainMoney();
                    form6.Show();
                }
            }
        }
Ejemplo n.º 15
0
        private void filter_Click(object sender, EventArgs e)
        {
            string markazID = GlobalVariable.markazID;

            using (var dbcontext = new Model.Context())
            {
                markaz marz = dbcontext.markazs.SingleOrDefault(x => x.ID == markazID);

                if (marz.final != 1)
                {
                    string parentID = marz.parent;
                    marz.title    = title.Text;
                    marz.masoul   = masool.Text;
                    marz.janeshin = janeshin.Text;
                    marz.BakhshID = "0";// bakhsh.SelectedValue.ToString();


                    List <markaz> lst = dbcontext.markazs.Where(x => x.parent == parentID).ToList();
                    foreach (markaz item in lst)
                    {
                        item.master = "0";
                    }
                    ;
                    marz.isDone = true;
                    marz.master = "1";
                    marz.final  = 1;
                    dbcontext.SaveChanges();
                }
                GlobalVariable.markazID = marz.parent;
            }

            this.Hide();
            Markaz_List form5 = new Markaz_List();

            form5.Show();
        }
Ejemplo n.º 16
0
        private void label7_Click(object sender, EventArgs e)
        {
            if (title.Text == "" || rially.Text == "" || dollari.Text == "")
            {
                messageLable.Text = "تمامی فیلد ها باید پر باشند";
            }
            else
            {
            }
            Model.ejraeiat model = new Model.ejraeiat()
            {
                dollaryP     = Int32.Parse(dollari.Text),
                riallyP      = Int32.Parse(rially.Text),
                title        = title.Text,
                shenasnameID = GlobalVariable.shenasnameID,
            };
            dbcontext.ejraeiats.Add(model);
            dbcontext.SaveChanges();
            int index = 0;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "Form6_PMainMoney")
                {
                    break;
                }

                index += 1;
            }
            this.Hide();

            Application.OpenForms[index].Close();
            Form6_PMainMoney form6 = new Form6_PMainMoney();

            form6.Show();
        }
Ejemplo n.º 17
0
        private void shenasnameAdd_Click(object sender, EventArgs e)
        {
            string     id          = RandomString(10);
            shenasname model       = new shenasname();
            DateTime   nowdatetime = DateTime.Now;

            model.token    = "123456789";
            model.master   = "1";
            model.ID       = id;
            model.parent   = id;
            model.date     = nowdatetime;
            model.dateFrom = DateTime.Now;
            model.dateTo   = DateTime.Now;
            model.time     = nowdatetime.TimeOfDay;
            dbcontext.shenasnames.Add(model);
            dbcontext.SaveChanges();
            GlobalVariable.shenasnameID = id;
            Form2_shenasnameAdd form = new Form2_shenasnameAdd();

            form.Show();


            this.Hide();
        }
Ejemplo n.º 18
0
        private void label2_Click(object sender, EventArgs e)
        {
            string itemname = itemList.SelectedItem.ToString();

            if (itemname == "")
            {
                return;
            }
            string shenasnameID = GlobalVariable.shenasnameID;

            using (var dbcontext = new Model.Context())
            {
                shenasname shen = dbcontext.shenasnames.SingleOrDefault(x => x.ID == shenasnameID);


                if (shen.final != 1)
                {
                    var    directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    string root      = Path.Combine(directory, "FIM");
                    System.IO.Directory.CreateDirectory(root);
                    string trashPath = Path.Combine(root, "asset");
                    System.IO.Directory.CreateDirectory(trashPath);

                    OpenFileDialog f = new OpenFileDialog();
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        string source = Path.GetFullPath(f.FileName);

                        string finalname    = "";
                        Random _random      = new Random();
                        string random       = _random.Next(10000, 99999).ToString();
                        string sourcAddress = source;
                        finalname = random + Path.GetExtension(sourcAddress);
                        string finalPath = trashPath + "\\" + finalname;

                        File.Copy(f.FileName, finalPath);
                        webBrowser1.Navigate(finalPath);



                        switch (itemname)
                        {
                        case "بایگانی موارد":
                            shen.bayganiFile = finalname;
                            break;

                        case "قرارداد":
                            shen.gharardadFile = finalname;
                            break;

                        case "متمم":
                            shen.motamamFile = finalname;
                            break;

                        case "پیوست متنی":
                            shen.peyvastFile = finalname;
                            break;

                        case "لیست مواد":
                            shen.listmavadFile = finalname;
                            break;

                        case "گانت چارت":
                            shen.gantFile = finalname;
                            break;

                        case "مجوز ستاد کل":
                            shen.mojavezFile = finalname;
                            break;

                        case "گزارش پیشرفت":
                            shen.pishraftFile = finalname;
                            break;
                        }
                        dbcontext.SaveChanges();

                        //factorPdf factor = new factorPdf(source);
                        //factor.Show();
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void label18_Click(object sender, EventArgs e)
        {
            string id = GlobalVariable.shenasnameID;

            Model.shenasname item = dbcontext.shenasnames.FirstOrDefault(x => x.ID == id);
            if (item.final != 1)
            {
                try
                {
                    item.DrasmiT         = Int32.Parse(DrasmiT.Text);
                    item.DrasmiHPR       = Int32.Parse(DrasmiHPR.Text);
                    item.DrasmiHPD       = Int32.Parse(DrasmiHPD.Text);
                    item.DgharartamamT   = Int32.Parse(DgharartamamT.Text);
                    item.DgharartamamHPR = Int32.Parse(DgharartamamHPR.Text);
                    item.DgharartamamHPD = Int32.Parse(DgharartamamHPD.Text);
                    item.DghararsaatT    = Int32.Parse(DghararsaatT.Text);
                    item.DghararsaatHPR  = Int32.Parse(DghararsaatHPR.Text);
                    item.DghararsaatHPD  = Int32.Parse(DghararsaatHPD.Text);
                    item.DvazifeT        = Int32.Parse(DvazifeT.Text);
                    item.DvazifeHPR      = Int32.Parse(DvazifeHPR.Text);
                    item.DvazifeHPD      = Int32.Parse(DvazifeHPD.Text);

                    item.ZDirasmiT         = Int32.Parse(ZDirasmiT.Text);
                    item.ZDirasmiHPR       = Int32.Parse(ZDirasmiTHPR.Text != "" ? ZDirasmiTHPR.Text : "0");
                    item.ZDirasmiHPD       = Int32.Parse(ZDirasmiHPD.Text);
                    item.ZDigharartamamT   = Int32.Parse(ZDigharartamamT.Text);
                    item.ZDigharartamamHPR = Int32.Parse(ZDigharartamamHPR.Text);
                    item.ZDigharartamamHPD = Int32.Parse(ZDigharartamamHPD.Text);
                    item.ZDighararsaatT    = Int32.Parse(ZDighararsaatT.Text);
                    item.ZDighararsaatHPR  = Int32.Parse(ZDighararsaatHPR.Text);
                    item.ZDighararsaatHPD  = Int32.Parse(ZDighararsaatHPD.Text);
                    item.ZDivazifeT        = Int32.Parse(ZDivazifeT.Text);
                    item.ZDivazifeHPR      = Int32.Parse(ZDivazifeHPR.Text);
                    item.ZDivazifeHPD      = Int32.Parse(ZDivazifeHPD.Text);

                    item.LrasmiT         = Int32.Parse(LrasmiT.Text);
                    item.LrasmiHPR       = Int32.Parse(LrasmiHPR.Text);
                    item.LrasmiHPD       = Int32.Parse(LrasmiHPD.Text);
                    item.LgharartamamT   = Int32.Parse(LgharartamamT.Text);
                    item.LgharartamamHPR = Int32.Parse(LgharartamamHPR.Text);
                    item.LgharartamamHPD = Int32.Parse(LgharartamamHPD.Text);
                    item.LghararsaatT    = Int32.Parse(LghararsaatT.Text);
                    item.LghararsaatHPR  = Int32.Parse(LghararsaatHPR.Text);
                    item.LghararsaatHPD  = Int32.Parse(LghararsaatHPD.Text);
                    item.LvazifeT        = Int32.Parse(LvazifeT.Text);
                    item.LvazifeHPR      = Int32.Parse(LvazifeHPR.Text);
                    item.LvazifeHPD      = Int32.Parse(LvazifeHPD.Text);

                    item.DirasmiT         = Int32.Parse(DirasmiT.Text);
                    item.DirasmiHPR       = Int32.Parse(DirasmiHPR.Text);
                    item.DirasmiHPD       = Int32.Parse(DirasmiHPD.Text);
                    item.DigharartamamT   = Int32.Parse(DigharartamamT.Text);
                    item.DigharartamamHPR = Int32.Parse(DigharartamamHPR.Text);
                    item.DigharartamamHPD = Int32.Parse(DigharartamamHPD.Text);
                    item.DighararsaatT    = Int32.Parse(DighararsaatT.Text);
                    item.DighararsaatHPR  = Int32.Parse(DighararsaatHPR.Text);
                    item.DighararsaatHPD  = Int32.Parse(DighararsaatHPD.Text);
                    item.DivazifeT        = Int32.Parse(DivazifeT.Text);
                    item.DivazifeHPR      = Int32.Parse(DivazifeHPR.Text);
                    item.DivazifeHPD      = Int32.Parse(DivazifeHPD.Text);

                    item.FLrasmiT         = Int32.Parse(FLrasmiT.Text);
                    item.FLrasmiHPR       = Int32.Parse(FLrasmiHPR.Text);
                    item.FLrasmiHPD       = Int32.Parse(FLrasmiHPD.Text);
                    item.FLgharartamamT   = Int32.Parse(FLgharartamamT.Text);
                    item.FLgharartamamHPR = Int32.Parse(FLgharartamamHPR.Text);
                    item.FLgharartamamHPD = Int32.Parse(FLgharartamamHPD.Text);
                    item.FLghararsaatT    = Int32.Parse(FLghararsaatT.Text);
                    item.FLghararsaatHPR  = Int32.Parse(FLghararsaatHPR.Text);
                    item.FLghararsaatHPD  = Int32.Parse(FLghararsaatHPD.Text);
                    item.FLvazifeT        = Int32.Parse(FLvazifeT.Text);
                    item.FLvazifeHPR      = Int32.Parse(FLvazifeHPR.Text);
                    item.FLvazifeHPD      = Int32.Parse(FLvazifeHPD.Text);

                    dbcontext.SaveChanges();
                    this.Hide();
                }
                catch
                {
                }
            }
            Form9_money_sarmaye form9 = new Form9_money_sarmaye();

            form9.Show();
            this.Hide();
        }
Ejemplo n.º 20
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int         iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex;
                int         rowindex           = dataGridView1.CurrentCell.RowIndex;
                int         rowID = Int32.Parse(dataGridView1.Rows[rowindex].Cells[2].Value.ToString());
                Model.tamin model = dbcontext.tamins.SingleOrDefault(x => x.ID == rowID);
                if (iSelectedGridIndex == 0)
                {
                    label1.Text      = "بانک تامین";
                    label1.ForeColor = Color.Black;

                    string imageName = model.imageName;
                    if (imageName != "")
                    {
                        var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                        try
                        {
                            if (Path.GetExtension(imageName) == ".pdf")
                            {
                                try
                                {
                                    //label1.Text = "takes too far";
                                    factorPdf factore = new factorPdf(directory + imageName);
                                    factore.Show();
                                }
                                catch (Exception error)
                                {
                                    label1.Text = error.InnerException.Message;
                                }
                            }
                            else
                            {
                                factorImage factor = new factorImage(directory + imageName);
                                factor.Show();
                            }
                        }
                        catch (Exception error)
                        {
                            label1.Text = "0000-" + error.InnerException.Message;
                        }
                    }
                }
                else if (iSelectedGridIndex == 1)
                {
                    string  IDsrt  = rowID.ToString();
                    archive rmodel = dbcontext.Archives.SingleOrDefault(x => x.shomareTamin == model.shomareSanad);
                    if (rmodel == null)
                    {
                        dbcontext.tamins.Remove(model);
                        dbcontext.SaveChanges();
                        List <Model.tamin> lst = (from p in dbcontext.tamins
                                                  where p.hesab == "0"
                                                  select p).OrderBy(x => x.ID).ToList();
                        dataGridView1.DataSource = lst;
                    }
                    else
                    {
                        label1.Text      = "تامین مورد نظر دارای فاکتور می باشد";
                        label1.ForeColor = Color.Red;
                    }
                }
            }
            catch (Exception er)
            {
                label1.Text = "111-" + er.InnerException.Message;
            }
        }
Ejemplo n.º 21
0
        private void filter_Click(object sender, EventArgs e)
        {
            var number = shomareSanad.Text;

            using (Model.Context dbcontext = new Model.Context())
            {
                tamin model = dbcontext.tamins.FirstOrDefault(x => x.shomareSanad == number);
                if (model != null)
                {
                    header.Text = "این شماره قبلا ثبت شده است";
                    return;
                }
            }



            if (radif.SelectedValue == null && subject.SelectedItem.ToString() != "سایر هزینه ها")
            {
                header.Text      = "ردیف انتخاب نشده است";
                header.ForeColor = Color.Red;
                return;
            }

            header.Text = "1";
            string sanad           = shomareSanad.Text;
            Int64  mbl             = Int64.Parse(price.Text);
            string prj             = project.SelectedValue.ToString();
            var    shenasname      = context.shenasnames.SingleOrDefault(x => x.ID == prj);
            string shenasnameID    = shenasname.ID;
            string shenasnameTitle = shenasname.title;
            string rd = subject.SelectedText != "مواد اولیه" ? "" : radif.SelectedValue.ToString();

            header.Text = "2";
            archive pastmodel = context.Archives.SingleOrDefault(x => x.hesab == "0" && x.shomareSanad == sanad && x.mablagh == mbl && x.shnesnameTitle == shenasnameTitle && x.radif == rd);

            if (pastmodel != null)
            {
                header.Text      = "برای پارامتر های موجود فاکتور انتخاب شده است";
                header.ForeColor = Color.Red;
                return;
            }



            functions fns       = new functions();
            var       directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);


            string mrk = "";

            mrk = (from sh in context.shenasnames
                   join ma in context.markazs on sh.markaz equals ma.parent
                   where sh.title == shenasnameTitle
                   select ma).First().title;


            header.Text = "3";
            string root = Path.Combine(directory, "FIM");

            System.IO.Directory.CreateDirectory(root);
            string taminPath = Path.Combine(root, "tamin");

            System.IO.Directory.CreateDirectory(taminPath);


            string trkh       = date.GetSelectedDateInPersianDateTime().ToShortDateString().Replace("/", "");
            string finalPrice = "";

            if (shomareSanad.Text == "")
            {
                header.Text      = "شماره سند را وارد نمایید";
                header.ForeColor = Color.Red;
                return;
            }
            if (price.Text == "")
            {
                header.Text      = "مبلغ را وارد نمایید";
                header.ForeColor = Color.Red;
                return;
            }

            float intprice = float.Parse(price.Text);

            if (intprice / 1000000 > 1)
            {
                finalPrice = (intprice / 1000000) + "MT";
            }
            else
            {
                finalPrice = (intprice / 1000) + "HT";
            }

            string finalname    = "";
            string random       = RandomNumber(10000, 99999).ToString();
            string sourcAddress = sourceLable.Text;

            finalname = random + Path.GetExtension(sourcAddress);

            imageName.Text = Path.Combine(taminPath, finalname).Replace(directory, "");
            string finalPath = taminPath + "\\" + finalname;


            //try
            //{
            //    System.IO.File.Delete(sourcAddress);
            //}
            //catch (IOException error)
            //{

            //}

            if (moneytype.SelectedItem == null)
            {
                header.Text      = "واحد پولی را انتخاب کنید";
                header.ForeColor = Color.Red;
                return;
            }

            if (pastmodel != null)
            {
                header.Text      = "برای پارامتر های موجود فاکتور انتخاب شده است";
                header.ForeColor = Color.Red;
                return;
            }



            //string rd = "";
            string rdTitle        = "";
            string choosenSubject = subject.Text;

            if (radif.SelectedValue != null)
            {
                rd = radif.SelectedValue.ToString();
                int intrd = Int32.Parse(rd);

                switch (choosenSubject)
                {
                case "اجراییات":
                    rdTitle = context.ejraeiats.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "سرمایه":
                    rdTitle = context.sarmayes.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "قرارداد":
                    rdTitle = context.gharardads.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "عمرانی":
                    rdTitle = context.omranis.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "اداری":
                    rdTitle = context.edaris.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "مصرفی":
                    rdTitle = context.masrafis.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "مواد":
                    rdTitle = context.sayers.SingleOrDefault(x => x.ID == intrd).title;
                    break;

                case "تشویقی":
                    rdTitle = context.tashvighis.SingleOrDefault(x => x.ID == intrd).title;
                    break;
                }
            }



            bool     isreferbish = referbish.Text == "0" ? false : true;
            string   sbj         = choosenSubject;
            DateTime trk         = date.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
            string   typ         = moneytype.SelectedItem.ToString();
            tamin    newITem     = new tamin()
            {
                radif          = rd,
                mablagh        = mbl,
                markaz         = "",
                project        = shenasnameID,
                shnesnameTitle = shenasnameTitle,
                radifTitle     = rdTitle,
                shomareSanad   = sanad,
                subject        = sbj,
                tarikh         = trk,
                type           = typ,
                hesab          = "0",
                imageName      = imageName.Text,
                //bankName = bank.Text,
                //checkNumber = checkNumber.Text,
                //referbish = isreferbish
            };

            context.tamins.Add(newITem);
            context.SaveChanges();
            webBrowser1.Navigate("http://localhost/");



            DataTable    dt        = new DataTable();
            tamin_Report taminform = new tamin_Report(dt);

            taminform.Show();
            this.Close();
            File.Move(sourcAddress, finalPath);
            try
            {
                File.Delete(sourcAddress);
            }
            catch (IOException error)
            {
            }
        }