Exemple #1
0
        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["email"].Value.ToString();
                AddCustomer addc = new AddCustomer();
                if (this.editcustid.Length == 0)
                {
                    if (addc.IsValidPhone(dataGridView1.Rows[e.RowIndex].Cells["phone"].Value.ToString()))
                    {
                        this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["phone"].Value.ToString();
                    }
                }
                if (this.editcustid.Length == 0)
                {
                    this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["custid"].Value.ToString();
                }
                label3.Text = this.editcustid;
            }

            // then perform your select statement according to that label
        }
 private void button1_Click(object sender, EventArgs e)
 {
     AddCustomer add = new AddCustomer();
     add.Show();
 }
        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {

            if (e.RowIndex != -1)
            {
                this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["email"].Value.ToString();
                AddCustomer addc = new AddCustomer();
                if (this.editcustid.Length == 0)
                {
                    if (addc.IsValidPhone(dataGridView1.Rows[e.RowIndex].Cells["phone"].Value.ToString()))
                    {
                        this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["phone"].Value.ToString();
                    }
                }
                if (this.editcustid.Length == 0)
                {
                    this.editcustid = dataGridView1.Rows[e.RowIndex].Cells["custid"].Value.ToString();
                }
                label3.Text = this.editcustid;
            }
            
            // then perform your select statement according to that label
        }
Exemple #4
0
        public void pouplateFields(string strip)
        {
            DataTable   dtedt  = new DataTable();
            AddCustomer addcus = new AddCustomer();
            Form1       fm1    = new Form1();

            if (strip.Length > 0)
            {
                if (strip.Contains("@") == true)
                {
                    dtedt         = fm1.getSelecteddatafromDB("email", this.holder);
                    this.colname1 = "email";
                }
                else if (addcus.IsValidPhone(strip))
                {
                    dtedt         = fm1.getSelecteddatafromDB("phone", this.holder);
                    this.colname1 = "phone";
                }
                else
                {
                    dtedt         = fm1.getSelecteddatafromDB("custid", this.holder);
                    this.colname1 = "custid";
                }
                if (dtedt.Rows.Count == 0)
                {
                    MessageBox.Show("No Records Found for " + this.colname1 + " value " + this.holder);
                    return;
                }
                this.fn                = dtedt.Rows[0]["firstname"].ToString();
                this.ln                = dtedt.Rows[0]["lastname"].ToString();
                this.em                = dtedt.Rows[0]["email"].ToString();
                this.ph                = dtedt.Rows[0]["phone"].ToString();
                this.ad                = dtedt.Rows[0]["address"].ToString();
                textBox1.Text          = this.fn;
                textBox2.Text          = this.ln;
                textBox3.Text          = this.em;
                textBox3.ReadOnly      = true;
                textBox4.Text          = this.ph;
                richTextBox1.Text      = this.ad;
                textBox1.ReadOnly      = true;
                textBox2.ReadOnly      = true;
                textBox4.ReadOnly      = true;
                richTextBox1.ReadOnly  = true;
                textBox1.BackColor     = Color.Green;
                textBox1.ForeColor     = Color.White;
                textBox2.BackColor     = Color.Green;
                textBox2.ForeColor     = Color.White;
                textBox3.BackColor     = Color.Green;
                textBox3.ForeColor     = Color.White;
                textBox4.BackColor     = Color.Green;
                textBox4.ForeColor     = Color.White;
                richTextBox1.BackColor = Color.Green;
                richTextBox1.ForeColor = Color.White;
                richTextBox1.Font      = new Font(richTextBox1.Font, FontStyle.Bold);
                button1.Enabled        = false;
                btnCancelEdit.Enabled  = false;
            }
            else
            {
                MessageBox.Show("Selected Record did not get value for Column", "Edit Customer", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddCustomer add = new AddCustomer();

            add.Show();
        }
        public void pouplateFields(string strip)
        {
             DataTable dtedt = new DataTable();
            AddCustomer addcus = new AddCustomer();
            Form1 fm1 = new Form1();
            if (strip.Length > 0)
            {
                if (strip.Contains("@") == true)
                {
                    dtedt = fm1.getSelecteddatafromDB("email", this.holder);
                    this.colname1 = "email";

                }
                else if (addcus.IsValidPhone(strip))
                {
                    dtedt = fm1.getSelecteddatafromDB("phone", this.holder);
                    this.colname1 = "phone";
                }
                else
                {
                    dtedt = fm1.getSelecteddatafromDB("custid", this.holder);
                    this.colname1 = "custid";
                }
                if (dtedt.Rows.Count == 0)
                {
                    MessageBox.Show("No Records Found for " + this.colname1 + " value " + this.holder);
                    return;
                }
                this.fn = dtedt.Rows[0]["firstname"].ToString();
                this.ln = dtedt.Rows[0]["lastname"].ToString();
                this.em = dtedt.Rows[0]["email"].ToString();
                this.ph = dtedt.Rows[0]["phone"].ToString();
                this.ad = dtedt.Rows[0]["address"].ToString();
                textBox1.Text = this.fn;
                textBox2.Text = this.ln;
                textBox3.Text = this.em;
                textBox3.ReadOnly = true;
                textBox4.Text = this.ph;
                richTextBox1.Text = this.ad;
                textBox1.ReadOnly = true;
                textBox2.ReadOnly = true;
                textBox4.ReadOnly = true;
                richTextBox1.ReadOnly = true;
                textBox1.BackColor = Color.Green;
                textBox1.ForeColor = Color.White;
                textBox2.BackColor = Color.Green;
                textBox2.ForeColor = Color.White;
                textBox3.BackColor = Color.Green;
                textBox3.ForeColor = Color.White;
                textBox4.BackColor = Color.Green;
                textBox4.ForeColor = Color.White;
                richTextBox1.BackColor = Color.Green;
                richTextBox1.ForeColor = Color.White;
                richTextBox1.Font = new Font(richTextBox1.Font, FontStyle.Bold);
                button1.Enabled = false;
                btnCancelEdit.Enabled = false;
            }
            else
            {
                MessageBox.Show("Selected Record did not get value for Column", "Edit Customer", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }