-->
جاري التحميل ...

007 Suplliers crud operations مشروع المبيعات سوبر ماركت وصيدليات سى شارب Entity Framework

-1-
-2-

 


using POSDemo.DB;

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.IO;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace POSDemo.Screens.suplliers

{

    public partial class fsuplliers : Form

    {

        POSTutEntities db = new POSTutEntities();

        string imagePath = "";

        int i;

       Supllier Supl;

=========================================

 

 

 

 

        public fsuplliers()

        {

            InitializeComponent();

            dataGridView1.DataSource = db.Suplliers.ToList();

        }

 

 

 

 

============================================

 

 

        void Clear()

        {

            txtName.Text =

               txtAddress.Text

               = txtNotes.Text

            = txtPhone.Text

              = txtCompany.Text

              = txtEmail.Text = "";

            isActive.Checked = false;

            pictureBox1.ImageLocation = "";

        }

 

 

 

==================================================================

 

 

        private void fsuplliers_Load(object sender, EventArgs e)

        {

 

        }

 

 

==========================================================================Save

 

 

 

 

        private void button1_Click(object sender, EventArgs e)

        {

            Supllier s= new Supllier();

 

           s.Name = txtName.Text;

            s.Address = txtAddress.Text;

            s.Notes = txtNotes.Text;

            s.Phone = txtPhone.Text;

            s.Company = txtCompany.Text;

            s.Email = txtEmail.Text;

            s.IsActive = isActive.Checked;

            db.Suplliers.Add(s);

            db.SaveChanges();

 

            if (imagePath != "")

            {

                // string destPath = Environment.CurrentDirectory + "\\images\\products\\" + p.Id + ".jpg";

                string destPath = "images\\suplliers\\" + s.id + ".jpg";

 

                File.Copy(imagePath, destPath, true);

                s.Image = destPath;

                db.SaveChanges();

            }

            dataGridView1.DataSource = db.Suplliers.ToList();

            MessageBox.Show("Submitted Successfully");

 

 

            Clear();

        }

 

 

 

 

 

========================================================================================= pictureBox1

 

 

 

 

 

 

        private void pictureBox1_Click(object sender, EventArgs e)

        {

            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == DialogResult.OK)

            {

                imagePath = dialog.FileName;

                pictureBox1.ImageLocation = dialog.FileName;

 

            }

        }

 

 

 

=========================================dataGridView1========================

 

 

 

 

 

 

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)

        {

            try

            {

                i = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());

                Supl = db.Suplliers.SingleOrDefault(x => x.id == i);

 

                txtName.Text = Supl.Name;

                txtAddress.Text = Supl.Address;

                txtNotes.Text = Supl.Notes;

                txtPhone.Text = Supl.Phone;

                txtCompany.Text = Supl.Company;

                txtEmail.Text = Supl.Email;

                isActive.Checked = (bool)Supl.IsActive;

 

                pictureBox1.ImageLocation = Supl.Image;

 

            }

            catch

            {

 

            }

        }

 

 

 

 

========================================================================  Update

-3-
-4-

التعليقات



إذا أعجبك محتوى مدونتنا نتمنى البقاء على تواصل دائم ، فقط قم بإدخال بريدك الإلكتروني للإشتراك في بريد المدونة السريع ليصلك جديد المدونة أولاً بأول ، كما يمكنك إرسال رساله بالضغط على الزر المجاور ...

إتصل بنا

جميع الحقوق محفوظة

مدونة كورس 7

2021