Ejemplo n.º 1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure want to insert data to database?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    if (IfCustExists(txtCustID.Text))
                    {
                        //Update data
                        uCust.cust_id         = Convert.ToInt32(txtCustID.Text);
                        uCust.cust_name       = txtCustName.Text;
                        uCust.cust_updtd_date = DateTime.Now;
                        uCust.cust_updtd_by   = 0;

                        //Updating data into database
                        bool success = dalCust.Update(uCust);

                        //if data is updated successfully then the value = true else false
                        if (success == true)
                        {
                            //data updated successfully
                            MessageBox.Show("Customer successfully updated ");
                            resetForm();
                        }
                        else
                        {
                            //failed to update user
                            MessageBox.Show("Failed to updated customer");
                        }
                    }
                    else
                    {
                        //Add data
                        uCust.cust_name       = txtCustName.Text;
                        uCust.cust_added_date = DateTime.Now;
                        uCust.cust_added_by   = 1;

                        //Inserting Data into Database
                        bool success = dalCust.Insert(uCust);
                        //If the data is successfully inserted then the value of success will be true else false
                        if (success == true)
                        {
                            //Data Successfully Inserted
                            MessageBox.Show("Customer successfully created");
                            resetForm();
                        }
                        else
                        {
                            //Failed to insert data
                            MessageBox.Show("Failed to add new customer");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            companysBLL tc      = new companysBLL();
            custBLL     c       = new custBLL();
            string      keyword = textcompany.Text;
            bool        sucess  = pDAL.chkcompanybyname(keyword);

            if (sucess == true)

            {
                MessageBox.Show("company found");
                tc = pDAL.GetcompanysForTransaction(keyword);
                int id = tc.id;
                c.cid    = id;
                c.nquery = 0;
            }
            else
            {
                addcompanys ca = new addcompanys();
                ca.Show();
            }
            c.name   = txtu_Name.Text;
            c.mobile = textmobile.Text;
            c.type   = texttyp.Text;
            c.email  = textemail.Text;
            tc       = pDAL.Search(textcompany.Text);
            sucess   = tDAL.Insert(c);

            if (sucess == true)
            {
                MessageBox.Show("costumer  added sucessfully");
                clear();
            }
            else
            {
                MessageBox.Show("costumer can not be added");
            }
        }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            string   keyword = txtu_Name.Text;
            queryBLL q       = new queryBLL();

            bool    qsucess = tDAL.chkcustumer(keyword);
            custBLL dc      = tDAL.searchcustumer(keyword);

            if (qsucess == true)
            {
                keyword = txtcompany.Text;
                companysBLL c = pDAL.Search(keyword);
                q.ques     = textqry.Text;
                q.soln     = textsoln.Text;
                q.cu_id    = dc.id;
                q.c_id     = dc.cid;
                q.u_name   = dc.name;
                emailname  = q.u_name;
                q.u_mobile = dc.mobile;
                dc.nquery  = dc.nquery++;
                bool incquery = tDAL.Increasenoofquery(dc); if (incquery == true)
                {
                    MessageBox.Show("user and query updated");
                }
                else
                {
                    MessageBox.Show("user and query not updated");
                }
                q.status = 1;
                bool success = dcDAL.Insert(q);
                q    = dcDAL.Getqueryforsearch(q);
                qid  = q.q_id;
                qid1 = q.q_id;
            }

            if (qsucess == false)
            {
                keyword = txtcompany.Text;
                bool csucess = pDAL.chkcompanybyname(keyword);
                if (csucess == true)
                {
                    keyword = txtcompany.Text;
                    companysBLL c = pDAL.Search(keyword);

                    custBLL ca = new custBLL();
                    ca.name   = txtu_Name.Text;
                    emailname = q.u_name;
                    ca.mobile = txtu_Contact.Text;
                    string type = "user";
                    ca.type  = type;
                    ca.email = txtemail.Text;
                    bool isadded = false;
                    int  id      = c.id;
                    ca.cid    = id;
                    ca.nquery = 0;
                    isadded   = tDAL.Insert(ca);
                    if (isadded == true)
                    {
                        MessageBox.Show("new user added");
                    }
                    else
                    {
                        MessageBox.Show("new user can not be added");
                    }
                }

                else
                {
                    MessageBox.Show("plz add new company");
                    addcompanys ca = new addcompanys();
                    ca.Show();
                }

                //space to add new user(custumer)
                //addnewcostumer costumer = new addnewcostumer();
                //costumer.Show();
                //this.Hide();
                //MessageBox.Show("plz add new costumer");
                //Failed to Add New product
                //MessageBox.Show("new user added");
            }


            //if the product is added successfully then the value of success will be true else it will be false
            if (qsucess == true)
            {
                //Product Inserted Successfully
                MessageBox.Show("query Added Successfully");


                emailsBLL email = new emailsBLL();
                email.to      = txtemail.Text;
                email.subject = "solidworks support query " + qid;
                string body = "<h3>" + "query- \n " + "</h3>" + "<b>" + textqry.Text + "</b>" + "<h3>" + " \n\n solution- \n" + "</h3>" + "<b>" + textsoln.Text + "</b>" + "\n\n\n\n\n";
                email.body = body;
                email.name = txtu_Name.Text;
                bool sucess = eDAL.sendemail(email);
                if (sucess == true)
                {
                    MessageBox.Show("email sent sucessfully");
                }
                else
                {
                    MessageBox.Show("email not sent");
                }
                //Calling the Clear Method
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region dal and bll
            custBLL     c  = new custBLL();
            custDAL     cd = new custDAL();
            queryBLL    q  = new queryBLL();
            queryDAL    qd = new queryDAL();
            companysBLL b  = new companysBLL();
            companysDAL dc = new companysDAL();
            #endregion
            #region query variables
            string ques;
            string ans;
            int    cid;
            string cname;
            #endregion
            #region user details
            //int id;
            string type = "user";
            string email;
            string name = "";
            string mobile;
            //int nquery;
            #endregion

            int i = dataGridView1.Rows.Count;
            i--;
            for (int j = 1; j < i; j++)

            {
                cname = dataGridView1.Rows[j].Cells[4].Value.ToString();
                bool sucess = cd.chkcustumer(cname);

                if (sucess == false)

                {
                    #region get data from table
                    name   = dataGridView1.Rows[j].Cells[4].Value.ToString();
                    mobile = dataGridView1.Rows[j].Cells[5].Value.ToString();
                    ans    = dataGridView1.Rows[j].Cells[3].Value.ToString();
                    email  = dataGridView1.Rows[j].Cells[6].Value.ToString();
                    cname  = dataGridView1.Rows[j].Cells[1].Value.ToString();
                    ques   = dataGridView1.Rows[j].Cells[2].Value.ToString();
                    #endregion
                    #region adding the user
                    bool isuser = cd.chkcustumer(name);
                    if (isuser == false)
                    {
                        c.name   = name;
                        c.mobile = mobile;
                        c.email  = email;
                        c.type   = type;
                        b        = dc.GetcompanysForTransaction(cname);
                        cid      = b.id;
                        c.cid    = cid;
                        c.nquery = 0;
                        bool useradded = cd.Insert(c);
                        bool qinc      = cd.Increasenoofquery(c);
                        if (useradded == false)
                        {
                            MessageBox.Show("user adding failed");
                        }
                    }

                    #endregion
                }
            }
        }