Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            custBLL     c  = new custBLL();
            custDAL     cd = new custDAL();
            queryBLL    q  = new queryBLL();
            queryDAL    qd = new queryDAL();
            companysBLL b  = new companysBLL();
            companysDAL dc = new companysDAL();


            #region user details
            //int id;

            string email;
            string name = "";
            string mobile;
            //int nquery;
            #endregion
            #region query details
            string ques;
            string ans;
            int    status = 1;
            int    cid;
            string cname;
            int    i = dataGridView1.Rows.Count;
            i--;
            #endregion

            for (int j = 1; j < i; j++)
            {
                #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 fill the query
                q.u_name   = name;
                q.u_mobile = mobile;
                q.ques     = ques;
                q.soln     = ans;
                q.status   = status;
                b          = dc.GetcompanysForTransaction(cname);
                cid        = b.id;
                q.c_id     = cid;
                bool isuser1 = cd.chkcustumer(name);
                if (isuser1 == true)
                {
                    c = cd.searchcustumer(name);
                }
                else
                {
                    MessageBox.Show("user not found");
                }
                q.cu_id  = c.id;
                q.status = status;
                bool qadded = qd.Insert(q);
                if (qadded == false)
                {
                    MessageBox.Show("query not added");
                }
                #endregion
            }
        }
Example #2
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
                }
            }
        }