private void button1_Click(object sender, EventArgs e)
        {
            String loggduser = Formlogin.loggdin;

            u.First_name = firstname.Text;
            u.Last_name  = lastname.Text;
            u.email      = Email.Text;
            u.username   = Username.Text;
            u.password   = Password.Text;
            u.contact    = Contact.Text;
            u.Address    = address.Text;
            u.user_type  = UserType.Text;
            u.added_date = DateTime.Now;

            userbll v = dal.getid(loggduser);

            u.added_by = v.id;
            bool success = dal.Insert(u);

            if (success == true)
            {
                MessageBox.Show("USER CREATED SUCCESFULLY");
                clear();
            }
            else
            {
                MessageBox.Show("FAILED TO ADD NEW USER");
            }
            DataTable dt = dal.Select();

            dataGridView1.DataSource = dt;
        }
Exemple #2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["name"] != null)
     {
         userbll   bll   = new userbll();
         userModel model = new userModel();
         model.name = TextBox1.Text;
         model.pwd  = TextBox2.Text;
         int num = bll.updata(model);
         if (num > 0)
         {
             ClientScript.RegisterStartupScript(GetType(), "", "alert('添加成功');window.location='index.aspx';", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "alert('失败');", true);
         }
     }
     else
     {
         userModel model = new userModel();
         model.name = TextBox1.Text;
         model.pwd  = TextBox2.Text;
         userbll bll = new userbll();
         int     num = bll.add(model);
         if (num > 0)
         {
             ClientScript.RegisterStartupScript(GetType(), "", "alert('添加成功');window.location='index.aspx';", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "alert('失败');", true);
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            v.Type  = comboType.Text;
            v.Name  = nme.Text;
            v.Email = email1.Text;


            v.Contact = contact1.Text;
            v.Address = address1.Text;

            v.added_date = DateTime.Now;
            string  loggduser = Formlogin.loggdin;
            userbll u         = udal.getid(loggduser);

            v.added_by = u.id;

            bool success = s.Insert(v);

            if (success == true)
            {
                MessageBox.Show("USER CREATED SUCCESFULLY");
                clear();
            }
            else
            {
                MessageBox.Show("FAILED TO ADD NEW USER");
            }
            DataTable dt = s.Select();

            dataGridView8.DataSource = dt;
        }
        public userbll getid(string name)
        {
            userbll       dc   = new userbll();
            SqlConnection conn = new SqlConnection(myconnstring);
            DataTable     dt   = new DataTable();

            try
            {
                String         sql     = "SELECT id FROM users_tbl WHERE username='******'";
                SqlCommand     cmd     = new SqlCommand(sql, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                conn.Open();
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    dc.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception e)

            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(dc);
        }
        public bool Delete(userbll u)
        {
            bool          issuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                String     sql = "DELETE FROM users_tbl where id=@id";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@id", u.id);

                conn.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    issuccess = true;
                }
                else
                {
                    issuccess = false;
                }
            }
            catch (Exception e)

            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(issuccess);
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            u2.Name     = name.Text;
            u2.Category = categorycmb.Text;

            u2.Description = description.Text;
            u2.Rate        = Decimal.Parse(rate.Text);
            u2.Qty         = Decimal.Parse(qty.Text);
            u2.added_date  = DateTime.Now;
            string  loggduser = Formlogin.loggdin;
            userbll u         = udal.getid(loggduser);

            u2.added_by = u.id;
            bool success = dal2.Insert(u2);

            if (success == true)
            {
                MessageBox.Show("Products added successfullY");
                clear();
            }
            else
            {
                MessageBox.Show("FAILED TO ADD NEW PRODUCT");
            }
            DataTable dt = dal2.Select();

            dataGridView1.DataSource = dt;
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            userbll bll = new userbll();

            Repeater1.DataSource = bll.sel();
            Repeater1.DataBind();
        }
Exemple #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         userbll bll = new userbll();
         if (Request.QueryString["name"] != null)
         {
             userModel model = bll.selname(Request.QueryString["name"].ToString());
             TextBox1.Text = model.name;
             TextBox2.Text = model.pwd;
         }
     }
 }
Exemple #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //账号 密码
            string  name   = TextBox1.Text;
            string  pwd    = TextBox2.Text;
            userbll bll    = new userbll();
            object  result = bll.login(name, pwd);

            if (result == null)
            {
                TextBox1.Text = "错误";
            }
            else
            {
                TextBox1.Text = "成功";
            }
        }
        public bool Update(userbll u)
        {
            bool          issuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                String     sql = "UPDATE  users_tbl SET First_name=@First_name,Last_name=@Last_name,email=@email,username=@username,password=@password,contact=@contact,Address=@Address,user_type=@user_type,added_date=@added_date,added_by=@added_by WHERE id=@id";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@First_name", u.First_name);
                cmd.Parameters.AddWithValue("@Last_name", u.Last_name);
                cmd.Parameters.AddWithValue("@email", u.email);
                cmd.Parameters.AddWithValue("@username", u.username);
                cmd.Parameters.AddWithValue("@password", u.password);
                cmd.Parameters.AddWithValue("@contact", u.contact);
                cmd.Parameters.AddWithValue("@Address", u.Address);
                cmd.Parameters.AddWithValue("@user_type", u.user_type);
                cmd.Parameters.AddWithValue("@added_date", u.added_date);
                cmd.Parameters.AddWithValue("@added_by", u.added_by);
                cmd.Parameters.AddWithValue("@id", u.id);
                conn.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    issuccess = true;
                }
                else
                {
                    issuccess = false;
                }
            }
            catch (Exception e)

            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }



            return(issuccess);
        }
        public bool Insert(userbll u)
        {
            bool          issuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                String     sql = "INSERT INTO users_tbl(First_name,Last_name,email,username,password,contact,Address,user_type,added_date,added_by) VALUES (@First_name,@Last_name,@email,@username,@password,@contact,@Address,@user_type,@added_date,@added_by)";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@First_name", u.First_name);
                cmd.Parameters.AddWithValue("@Last_name", u.Last_name);
                cmd.Parameters.AddWithValue("@email", u.email);
                cmd.Parameters.AddWithValue("@username", u.username);
                cmd.Parameters.AddWithValue("@password", u.password);
                cmd.Parameters.AddWithValue("@contact", u.contact);
                cmd.Parameters.AddWithValue("@Address", u.Address);
                cmd.Parameters.AddWithValue("@user_type", u.user_type);
                cmd.Parameters.AddWithValue("@added_date", u.added_date);
                cmd.Parameters.AddWithValue("@added_by", u.added_by);
                conn.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    issuccess = true;
                }
                else
                {
                    issuccess = false;
                }
            }
            catch (Exception e)

            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }



            return(issuccess);
        }
Exemple #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            u1.Title       = title.Text;
            u1.Description = description.Text;
            u1.added_date  = DateTime.Now;
            string  loggduser = Formlogin.loggdin;
            userbll u         = udal.getid(loggduser);

            u1.added_by = u.id;
            bool success = dal1.Insert(u1);

            if (success == true)
            {
                MessageBox.Show("CATEGORY CREATED SUCCESFULLY");
                clear();
            }
            else
            {
                MessageBox.Show("FAILED ");
            }
        }
Exemple #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            Transactionbll transaction = new Transactionbll();

            transaction.Type = label1.Text;
            string dea_csname = dcname.Text;
            DCbll  dc         = dcdal.getid(dea_csname);

            transaction.dea_cust_id      = dc.id;
            transaction.Grand_total      = Math.Round(decimal.Parse(grandtotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(vat.Text);
            transaction.discount = decimal.Parse(discount.Text);
            string  usrname = Formlogin.loggdin;
            userbll u       = udal.getid(usrname);

            transaction.added_by           = u.id;
            transaction.transactiondetails = transactiondt;

            bool success = false;

            //inserting transaction and transaction details
            using (TransactionScope scope = new TransactionScope())

            {
                int  transactionid = -1;
                bool w             = tdal.Insert(transaction, out transactionid);

                for (int i = 0; i < transactiondt.Rows.Count; i++)
                {
                    trnsctiondetailbll tddetail = new trnsctiondetailbll();
                    String             prdname  = transactiondt.Rows[i][0].ToString();
                    productsbll        p        = pdal.getpid(prdname);
                    tddetail.pid = p.id;

                    tddetail.rate        = decimal.Parse(transactiondt.Rows[i][1].ToString());
                    tddetail.qty         = decimal.Parse(transactiondt.Rows[i][2].ToString());
                    tddetail.Total       = Math.Round(decimal.Parse(transactiondt.Rows[i][3].ToString()), 2);
                    tddetail.dea_cust_id = dc.id;
                    tddetail.added_date  = DateTime.Now;
                    tddetail.added_by    = u.id;
                    //INC OR DEC QTY
                    string ttype = label1.Text;
                    bool   x     = false;
                    if (ttype == "PURCHASE")
                    {
                        x = pdal.increaseqty(tddetail.pid, tddetail.qty);
                    }
                    else if (ttype == "SALES")
                    {
                        x = pdal.decreaseqty(tddetail.pid, tddetail.qty);
                    }



                    bool y = tddal.Insert(tddetail);

                    success = w && y && x;
                }
                if (success == true)
                {
                    scope.Complete();
                    DGVPrinter print = new DGVPrinter();
                    print.Title               = "\r\n\r\n MIKE'S STORES  PVT LTD \r\n";
                    print.SubTitle            = "KOCHI ,KERALA ,phone - +919537583616\r\n\r\n";
                    print.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    print.PageNumbers         = true;
                    print.PageNumberInHeader  = false;
                    print.PorportionalColumns = true;
                    print.HeaderCellAlignment = StringAlignment.Near;
                    print.Footer              = "Discount :" + discount.Text + "% \r\n" + "vat :" + vat.Text + "%\r\n" + "GRAND_TOTAL:" + grandtotal.Text + "\r\n" + "Date & time of purchase:" + dateTimePicker1.Value + "\r\n\r" + " THANK YOU";
                    print.FooterSpacing       = 40;
                    print.PrintDataGridView(dgvproducts);

                    MessageBox.Show("TRANSACTION C0MPLETED SUCCESSFULLY");
                    dgvproducts.DataSource = null;
                    dgvproducts.Rows.Clear();
                    dgvproducts.DataSource = null;
                    dgvproducts.Rows.Clear();
                    dcsearch.Text  = "";
                    dcname.Text    = "";
                    dcemail.Text   = "";
                    dccontact.Text = "";
                    dcaddress.Text = "";
                    clear();
                    sbtotal.Text    = "";
                    discount.Text   = "0";
                    grandtotal.Text = "0";
                    vat.Text        = "0";
                    PA.Text         = "0";
                    RA.Text         = "0";
                }



                else
                {
                    MessageBox.Show("TRANSACTION FAILED");
                }
            }
        }