Exemple #1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            DataTable      dt   = new DataTable();
            daryaftiReport form = new daryaftiReport(dt);

            form.Show();
            this.Hide();
        }
Exemple #2
0
        private void filter_Click(object sender, EventArgs e)
        {
            DateTime trkFrom = dateFrom.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
            DateTime trkTo   = dateTo.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
            Int64    prcFrom = Int64.Parse(priceFrom.Text);
            Int64    prcTo   = Int64.Parse(priceTo.Text);

            List <Model.archive> lst = new List <archive>();
            var    plist             = (from p in context.Archives select p);
            string prj = "";

            if (project.SelectedValue != null)
            {
                prj = project.SelectedValue.ToString();
            }
            List <archive> lst2 = plist.ToList();

            if (project.SelectedItem != null)
            {
                plist = plist.Where(x => x.project == prj);
            }


            if (markaz.Text != "")
            {
                plist = plist.Where(x => x.markaz == markaz.Text);
            }
            if (shomareSanad.Text != "")
            {
                plist = plist.Where(x => x.shomareSanad == shomareSanad.Text);
            }

            if (moneytype.Text != "")
            {
                plist = plist.Where(x => x.type == moneytype.Text);
            }
            if (true)
            {
                plist = plist.Where(x => x.hesab == "1");
                plist = plist.Where(x => x.tarikh >= trkFrom && x.tarikh <= trkTo);
                plist = plist.Where(x => x.mablagh >= prcFrom && x.mablagh <= prcTo);
            }
            lst = plist.ToList();


            DataTable      dt       = ToDataTable(lst);
            daryaftiReport daryafti = new daryaftiReport(dt);

            daryafti.Show();
        }
Exemple #3
0
        private void filter_Click(object sender, EventArgs e)
        {
            string sourcAddress = sourceLable.Text;

            int  index       = 0;
            int  indeximage  = 0;
            bool factorimage = false;
            int  indexpdf    = 0;
            bool factorpdf   = false;

            foreach (Form form in Application.OpenForms)
            {
                if (form.Name == "factorPdf")
                {
                    factorpdf = true;
                    indexpdf  = index;
                    break;
                }
                if (form.Name == "factorImage")
                {
                    factorimage = true;
                    indeximage  = index;
                    break;
                }
                index += 1;
            }
            if (factorimage == true)
            {
                Application.OpenForms[indeximage].Close();
            }
            if (factorpdf == true)
            {
                Application.OpenForms[indexpdf].Close();
            }

            Context dbcontext = new Context();
            string  sanad     = shomareSanad1.Text;

            string prj             = project.SelectedValue.ToString();
            var    shenasname      = dbcontext.shenasnames.SingleOrDefault(x => x.ID == prj);
            string shenasnameID    = shenasname.ID;
            string shenasnameTitle = shenasname.title;

            var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);


            string mrk       = "";
            var    mrkobject = (from sh in dbcontext.shenasnames
                                join ma in dbcontext.markazs on sh.markaz equals ma.parent
                                where sh.title == shenasnameTitle
                                select ma);

            if (mrkobject != null)
            {
                mrk = mrkobject.First().title;
            }



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

            System.IO.Directory.CreateDirectory(root);
            string markazPath = Path.Combine(root, mrk);

            System.IO.Directory.CreateDirectory(markazPath);
            string shenasnamePath = Path.Combine(markazPath, shenasnameTitle);

            System.IO.Directory.CreateDirectory(shenasnamePath);
            string pardPath = Path.Combine(shenasnamePath, "فاکتور های دریافتی");

            System.IO.Directory.CreateDirectory(pardPath);


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

            if (shomareSanad1.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 = "";

            if (bank.Text == "")
            {
                finalname = "تامینی" + "_" + shomareSanad1.Text + Path.GetExtension(sourcAddress);
            }
            else
            {
                finalname = trkh + "_" + finalPrice + "_" + bank.Text + Path.GetExtension(sourcAddress);
            }

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

            webBrowser1.Navigate("http://localhost/.");



            archive pastmodel = dbcontext.Archives.SingleOrDefault(x => x.hesab == "1" && x.shomareSanad == sanad && x.shnesnameTitle == shenasnameTitle && referbish.Text == "0" && x.type == moneytype.Text);

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

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

            DateTime trk = date.GetSelectedDateInPersianDateTime().ToShortDateString().ToGeorgianDateTime();
            string   typ = moneytype.SelectedItem.ToString();


            bool    isreferbish = referbish.Text == "0" ? false : true;
            long    mbl         = (long)intprice;
            archive newITem     = new archive()
            {
                mablagh        = mbl,
                markaz         = "",
                project        = shenasnameID,
                shnesnameTitle = shenasnameTitle,
                shomareSanad   = sanad,
                tarikh         = trk,
                type           = typ,
                hesab          = "1",
                imageName      = imageName.Text,
                bankName       = bank.Text,
                checkNumber    = sanadType.Text,
                referbish      = isreferbish,
                subject        = subject.Text
            };

            dbcontext.Archives.Add(newITem);
            dbcontext.SaveChanges();



            DataTable      dt         = new DataTable();
            daryaftiReport daryaftirp = new daryaftiReport(dt);

            daryaftirp.Show();
            this.Close();

            System.IO.File.Move(sourcAddress, finalPath);
        }