Mobile Shop Management Tutorial Part 1

1:48 AM
Create Mobile Shop Management Software in C# Visual Studio 2010
1. Product Master
2. Sale Form
3. Purchase Form
4. Mobile Stock List
5. Sale Report
6. Purchase Report
7. Mobile Stock Report

Hello Friends I am Amin Sati Today I will Teach You Create Product Master  Window Form  in C# Language VS 2010.




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MobileShop
{
    public partial class Frm_Product : Form
    {
        string FF_NUMBER;
        int c = 1;
        int r_id;
        int r;
       
        string SCON=@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Amin Sati\Documents\DB_MOBILE.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        SqlConnection CON;
        SqlCommand CMD=new SqlCommand ();
        public Frm_Product()
        {
            InitializeComponent();
        }

        private void BTN_SAVE_Click(object sender, EventArgs e)
        {
            if (BTN_SAVE.Text == "&Update")
            {
                string st1="update tbl_product set f_company='"+TXT_COMPANY.Text +"',f_modelno='"+TXT_MODEL.Text +"' where f_number='"+FF_NUMBER+"'";
                 CON = new SqlConnection(SCON);
                CON.Open();
                CMD.Connection = CON;
                CMD.CommandText = st1;
                CMD.ExecuteNonQuery();
            }
            else
            {
                string STR = "INSERT INTO TBL_PRODUCT (F_COMPANY,F_MODELNO) VALUES('" + TXT_COMPANY.Text + "','" + TXT_MODEL.Text + "')";
                CON = new SqlConnection(SCON);
                CON.Open();
                CMD.Connection = CON;
                CMD.CommandText = STR;
                CMD.ExecuteNonQuery();
                MessageBox.Show("INSERTION SUCCESSFULLY");
            }
            RESET();
        }
        private void RESET()
        {
            TXT_COMPANY .Text ="";
            TXT_MODEL.Text ="";
            TXT_COMPANY .Focus ();
            funshow();
            FF_NUMBER = "";
            BTN_SAVE.Text = "&Save";

        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RESET();
        }
        //FOR TAB_CONTROL PAST WITH THE USE OF ENTER KEY
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (msg.WParam.ToInt32())
            {
                case 13:
                    if (this.ActiveControl is TextBox)
                    {
                        SendKeys.Send("{Tab}");
                        return true;
                    }
                    if (this.ActiveControl is ComboBox)
                    {
                        SendKeys.Send("{Tab}");
                        return true;
                    }
                    if (this.ActiveControl is DateTimePicker)
                    {
                        SendKeys.Send("{Tab}");
                        return true;
                    }

                    break;


            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
        //FOR ADJUST GRIDVIEW SIZE
        private void viewadjust()
        {
            DGW_ITEM.Columns[0].Width = 50;
            DGW_ITEM.Columns[1].Width = 120;
            DGW_ITEM.Columns[0].HeaderText = "CODE";
            DGW_ITEM.Columns[1].HeaderText = "COMPANY";
            DGW_ITEM.Columns[2].HeaderText = "MODEL NO.";


        }
        //FOR DISPLAY TABLE DATA IN GRIDVIEW
        private void funshow()
        {

            string selectq = "";
            selectq = "select F_NUMBER,F_COMPANY,F_MODELNO from tbl_product";
            DataSet ds1 = new DataSet();
            CON = new SqlConnection(SCON);
            CON.Open();
            SqlDataAdapter AD = new SqlDataAdapter(selectq, CON);
            AD.Fill(ds1);
            DGW_ITEM.DataSource = ds1.Tables[0];
            viewadjust();
            totshow();
        }
        //FOR COUNT TOTAL RECORD
        private void totshow()
        {
            int counting;
            int no1 = 0;
            counting = DGW_ITEM.Rows.Count;
            for (int k = 0; k < counting; k++)
            {
                no1 = no1 + 1;
            }
            LBL_NO.Text = "No. of Record : " + no1.ToString();
        }

        //drag dro form
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x84:
                    base.WndProc(ref m);
                    if ((int)m.Result == 0x1)
                        m.Result = (IntPtr)0x2;
                    return;
            }

            base.WndProc(ref m);
        }

        private void Frm_Product_Load(object sender, EventArgs e)
        {
            RESET();
        }

        private void btn_edit_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 rc = DGW_ITEM.ColumnCount;
                r_id = int.Parse(DGW_ITEM.Rows[r].Cells[0].Value.ToString());

                FF_NUMBER = DGW_ITEM.Rows[r].Cells[0].Value.ToString();
                TXT_COMPANY.Text = DGW_ITEM.Rows[r].Cells[1].Value.ToString();
                TXT_MODEL.Text = DGW_ITEM.Rows[r].Cells[2].Value.ToString();


                BTN_SAVE.Text = "&Update";
                TXT_COMPANY.Focus();
            }
            catch (Exception)
            {
                MessageBox.Show("Please Select Record First", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TXT_COMPANY.Focus();

            }
        }

        private void btn_remove_Click(object sender, EventArgs e)
        {
            try
            {
                int v1 = int.Parse(DGW_ITEM.Rows[r].Cells[0].Value.ToString());
                string na = DGW_ITEM.Rows[r].Cells[0].Value.ToString();
                string delq = "Delete from tbl_PRODUCT where F_NUMBER=" + v1 + "";
                CON = new SqlConnection(SCON);
                CON.Open();
                CMD.Connection = CON;
                CMD.CommandText = delq;
                CMD.ExecuteNonQuery();
                MessageBox.Show("Record Has been Deleted Successfully(  " + na.ToUpper() + "  )", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);

                RESET();
            }
            catch (Exception er)
            {
                MessageBox.Show("Please Select Record First", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TXT_COMPANY.Focus();


            }
        }

        private void DGW_ITEM_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            r = e.RowIndex;
        }
      
    }
}




Thanks For watching My video Friends if You want More Like that Programs then Subscribe My Channel.
contact me: (For Source Code And Designing Trick)
www.fb.com/AminSati786
www.plus.google.com/+aminsati
whatsapp number +918140005015
Comment me Your Mail ID I will Send You Source Code Thank You,

Share this

Related Posts

Previous
Next Post »