コード例 #1
0
ファイル: ChooseBank.cs プロジェクト: puremere/mostaan
        private void Daryafti_Click(object sender, EventArgs e)
        {
            DataTable    dt   = new DataTable();
            tamin_Report form = new tamin_Report(dt);

            form.Show();
            this.Hide();
        }
コード例 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (Context dbcontext = new Context())
     {
         List <Model.tamin> lst = dbcontext.tamins.Where(c => !dbcontext.Archives.Select(b => b.shomareTamin).Contains(c.shomareSanad)).ToList();
         tamin_Report       tr  = new tamin_Report(ToDataTable(lst));
         tr.Show();
     }
 }
コード例 #3
0
ファイル: tamin_New.cs プロジェクト: puremere/mostaan
        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)
            {
            }
        }