Ejemplo n.º 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            using (var dbcontext = new Model.Context())
            {
                int           iSelectedGridIndex = dataGridView1.CurrentCell.ColumnIndex;
                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);
                string        imageName = "";
                if (iSelectedGridIndex == 1)
                {
                    imageName = model.imageName;
                }
                else if (iSelectedGridIndex == 0)
                {
                    Model.tamin tmodel = dbcontext.tamins.SingleOrDefault(x => x.shomareSanad == model.shomareTamin);
                    imageName = tmodel.imageName;
                }

                if (imageName != "")
                {
                    try
                    {
                        var directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

                        if (Path.GetExtension(imageName) == ".pdf")
                        {
                            try
                            {
                                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)
                    {
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public tamincheck(string id)
        {
            InitializeComponent();
            FontClass fontclass = new FontClass();

            this.MaximizeBox = false;
            this.CenterToScreen();
            List <Control> allControls = fontclass.GetAllControls(this);

            allControls.ForEach(k => k.Font = mostaan.GlobalVariable.headerlistFONTsmall);

            Model.tamin model = context.tamins.SingleOrDefault(x => x.shomareSanad == id);
            shenasname.Text = model.shnesnameTitle;
            jadval.Text     = model.subject;
            radif.Text      = model.radifTitle;
            gheymat.Text    = model.mablagh.ToString();
            vahed.Text      = model.type;
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var id = tamin.Text;

            try
            {
                Model.tamin tmodel = context.tamins.SingleOrDefault(x => x.shomareSanad == id);
                if (tmodel != null)
                {
                    gheymat.Text = tmodel.mablagh.ToString();
                }
                tamincheck model = new tamincheck(id);
                model.Show();
            }
            catch (Exception)
            {
                header.Text      = "شماره سند مورد نظر یافت نشد";
                header.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 4
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;
            }
        }