protected void customerGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global_Connection gc  = new Global_Connection();
            SqlCommand        cmd = new SqlCommand();

            cmd.Connection = gc.cn;
            string         index   = Convert.ToString(e.CommandArgument);
            string         strData = "Select * From customer Where mid='" + index + "'";
            SqlDataAdapter da      = new SqlDataAdapter(strData, gc.cn);
            DataSet        ds      = new DataSet();

            da.Fill(ds, "tbl_customer1");
            DataTable dt = ds.Tables[0];

            //.Text = dt.Rows[0]["mid"].ToString();
            txtCustomerName.Text    = dt.Rows[0]["name"].ToString();
            txtCustomerAddress.Text = dt.Rows[0]["address"].ToString();
            txtPhone.Text           = dt.Rows[0]["phone"].ToString();
            txtEmail.Text           = dt.Rows[0]["email"].ToString();
            cmboMember.Text         = dt.Rows[0]["memberType"].ToString();
            lblId.Text        = dt.Rows[0]["mid"].ToString();
            btnAdd.Visible    = false;
            btnDelete.Visible = true;
            btnUpdate.Visible = true;
        }
示例#2
0
        protected void itemGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global_Connection gc  = new Global_Connection();
            SqlCommand        cmd = new SqlCommand();

            cmd.Connection = gc.cn;
            string         index   = Convert.ToString(e.CommandArgument);
            string         strData = "Select * From item Where itemId='" + index + "'";
            SqlDataAdapter da      = new SqlDataAdapter(strData, gc.cn);
            DataSet        ds      = new DataSet();

            da.Fill(ds, "item");
            DataTable dt = ds.Tables[0];

            //.Text = dt.Rows[0]["mid"].ToString();
            txtItemName.Text           = dt.Rows[0]["name"].ToString();
            txtDescription.Text        = dt.Rows[0]["description"].ToString();
            txtItemPrice.Text          = dt.Rows[0]["price"].ToString();
            txtItemQty.Text            = dt.Rows[0]["quantity"].ToString();
            txtPurchaseDate.Text       = dt.Rows[0]["purchaseDate"].ToString();
            cmboCategory.SelectedValue = dt.Rows[0]["category"].ToString();
            cmboSupplier.SelectedValue = dt.Rows[0]["supplier"].ToString();
            lblId.Text        = dt.Rows[0]["itemId"].ToString();
            btnAdd.Visible    = false;
            btnUpdate.Visible = true;
        }
示例#3
0
        protected void categoryGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global_Connection gc  = new Global_Connection();
            SqlCommand        cmd = new SqlCommand();

            cmd.Connection = gc.cn;
            string         index   = Convert.ToString(e.CommandArgument);
            string         strData = "Select * From category Where categoryId='" + index + "'";
            SqlDataAdapter da      = new SqlDataAdapter(strData, gc.cn);
            DataSet        ds      = new DataSet();

            da.Fill(ds, "category");
            DataTable dt = ds.Tables[0];

            //.Text = dt.Rows[0]["mid"].ToString();
            txtCategoryName.Text = dt.Rows[0]["categoryName"].ToString();
            lblId.Text           = dt.Rows[0]["categoryId"].ToString();
        }
示例#4
0
        protected void supplierGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global_Connection gc  = new Global_Connection();
            SqlCommand        cmd = new SqlCommand();

            cmd.Connection = gc.cn;
            string         index   = Convert.ToString(e.CommandArgument);
            string         strData = "Select * From supplier Where supplierId='" + index + "'";
            SqlDataAdapter da      = new SqlDataAdapter(strData, gc.cn);
            DataSet        ds      = new DataSet();

            da.Fill(ds, "supplier");
            DataTable dt = ds.Tables[0];

            //.Text = dt.Rows[0]["mid"].ToString();
            txtSupplierName.Text  = dt.Rows[0]["supplierName"].ToString();
            txtAddress.Text       = dt.Rows[0]["address"].ToString();
            txtPhoneNumber.Text   = dt.Rows[0]["phone"].ToString();
            txtSupplierEmail.Text = dt.Rows[0]["email"].ToString();
            lblId.Text            = dt.Rows[0]["supplierId"].ToString();
        }
示例#5
0
        protected void userGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global_Connection gc  = new Global_Connection();
            SqlCommand        cmd = new SqlCommand();

            cmd.Connection = gc.cn;
            string         index   = Convert.ToString(e.CommandArgument);
            string         strData = "Select * From credential Where id='" + index + "'";
            SqlDataAdapter da      = new SqlDataAdapter(strData, gc.cn);
            DataSet        ds      = new DataSet();

            da.Fill(ds, "credential");
            DataTable dt = ds.Tables[0];

            //.Text = dt.Rows[0]["mid"].ToString();
            txtUsername.Text     = dt.Rows[0]["username"].ToString();
            txtEmail.Text        = dt.Rows[0]["email"].ToString();
            txtPassword.Text     = dt.Rows[0]["password"].ToString();
            checkIsAdmin.Checked = bool.Parse(dt.Rows[0]["isAdmin"].ToString());
            lblId.Text           = dt.Rows[0]["id"].ToString();
            btnAddUser.Visible   = false;
            btnUpdate.Visible    = true;
        }
示例#6
0
 public String AddSale(double totalAmount, int customerId, int staffId, int itemId, int quantity)
 {
     try
     {
         DateTime          date = DateTime.Today;
         Global_Connection gc   = new Global_Connection();
         SqlCommand        cmd  = new SqlCommand("Insert into sales(totalAmount, dateTime, customerId, staffId, itemId, quantity) values(@totalAmount, @dateTime, @customerId, @staffId, @itemId, @quantity)", gc.cn);
         // cmd.Parameters.AddWithValue("@category", Category);
         cmd.Parameters.AddWithValue("@totalAmount", totalAmount);
         cmd.Parameters.AddWithValue("@dateTime", date);
         cmd.Parameters.AddWithValue("@customerId", customerId);
         cmd.Parameters.AddWithValue("@staffId", staffId);
         cmd.Parameters.AddWithValue("@itemId", itemId);
         cmd.Parameters.AddWithValue("@quantity", quantity);
         cmd.ExecuteNonQuery();
         gc.cn.Close();
         return(ChangeQuantity(itemId, quantity));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }