[Solved] ASP.Net Error: The modifier public is not valid for this item

micah
 
on Nov 03, 2021 08:05 AM
794 Views

All the public void on this page is having error.

Error CS0106 The modifier public is not valid for this item

namespace Ebuka
{
    public partial class CreatStock : System.Web.UI.Page
    {
        static int Id = 0;
        private static string constring4 = ConfigurationManager.ConnectionStrings["DB"].ToString();
        static string str = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
        //SqlConnection con = null;
        SqlCommand cmd = null;
        SqlDataReader dr = null;
        static string username = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                string Constr1 = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
                using (SqlConnection CONE = new SqlConnection(Constr1))
                {
                    using (SqlCommand C0MDE = new SqlCommand("SELECT ID, Store FROM Stores "))
                    {
                        C0MDE.CommandType = CommandType.Text;
                        C0MDE.Connection = CONE;
                        CONE.Open();
                        Department.DataSource = C0MDE.ExecuteReader();
                        Department.DataValueField = "ID";
                        Department.DataTextField = "Store";
                        // ddlProductCode.DataValueField = "UserName";
                        Department.DataBind();
                        CONE.Close();
                    }
                }
                Department.Items.Insert(0, new ListItem("--Select Store--", "0"));
            }
 
            if (!this.IsPostBack)
            {
                string Constr1 = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
                using (SqlConnection CONE = new SqlConnection(Constr1))
                {
                    using (SqlCommand C0MDE = new SqlCommand("SELECT ID, CategoryName FROM Categories "))
                    {
                        C0MDE.CommandType = CommandType.Text;
                        C0MDE.Connection = CONE;
                        CONE.Open();
                        ddlbrand.DataSource = C0MDE.ExecuteReader();
                        ddlbrand.DataValueField = "ID";
                        ddlbrand.DataTextField = "CategoryName";
                        // ddlProductCode.DataValueField = "UserName";
                        ddlbrand.DataBind();
                        CONE.Close();
                    }
                }
                ddlbrand.Items.Insert(0, new ListItem("--Select Category Name--", "0"));
            }
            if (!Page.IsPostBack)
            {
                string conStr = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
                SqlConnection con = new SqlConnection(conStr);
                DataSet ds = new DataSet();
                try
                {
                    con.Open();
                    string sql = "SELECT C_ID, Item FROM Itemprice";
                    SqlDataAdapter da = new SqlDataAdapter(sql, con);
                    da.Fill(ds);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
                finally
                {
                    ds.Dispose();
                    con.Close();
                }
            }
        }
 
        protected void ddlbrand_SelectedIndexChanged(object sender, EventArgs e)
        {
            string constr = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                SqlCommand command = new SqlCommand("SELECT Item, Stock_Remaining FROM Warehouse_Table WHERE Item=@Item", con);
                command.Parameters.AddWithValue("@Item", ddlbrand.SelectedItem.Text);
                //command.Parameters.AddWithValue("@Store", Department.SelectedItem.Text);
                con.Open();
                SqlDataReader sdr = command.ExecuteReader();
                if (sdr.Read())
                {
                    txtock.Text = sdr["Stock_Remaining"].ToString();
                    //  txtname.Text = sdr["Name"].ToString();
                    // DropDownList1.SelectedItem.Text = sdr["ID"].ToString();
                    //txtphone.Text = sdr["Phone"].ToString();
                    // txtaddress.Text = sdr["Address"].ToString();
                    //  txtvenue.Text = sdr["Venue"].ToString();
                    //  txtfee.Text = sdr["After_Discount"].ToString();
 
                }
                sdr.Close();
            }
        }
 
        protected void btncustomer_Click(object sender, EventArgs e)
        {
            if (Department.SelectedIndex < 1)
            {
                //   MessageBox1.ShowError("Enter Date Please");
                ScriptManager.RegisterClientScriptBlock(btncustomer, this.GetType(), "alert", "<script>alert('Select Store  ... !!')</script>", false);
            }
            else
            {
                lblMessage2.Text = "";
                if (txtassign.Text == "")
                {
                    //   MessageBox1.ShowError("Enter Date Please");
                    ScriptManager.RegisterClientScriptBlock(btncustomer, this.GetType(), "alert", "<script>alert('Enter Quantity ... !!')</script>", false);
                }
                else
                {
                    lblMessage2.Text = "";
                    if (txtdate.Text == "")
                    {
                        //   MessageBox1.ShowError("Enter Date Please");
                        ScriptManager.RegisterClientScriptBlock(btncustomer, this.GetType(), "alert", "<script>alert('Enter Date ... !!')</script>", false);
                    }
                    else
                    {
                        lblMessage2.Text = "";
                        if (ddlbrand.SelectedItem.Text == "")
                        {
                            //   MessageBox1.ShowError("Enter Date Please");
                            ScriptManager.RegisterClientScriptBlock(btncustomer, this.GetType(), "alert", "<script>alert('Select Brand  ... !!')</script>", false);
                        }
                        else
                        {
                            lblMessage2.Text = "";
                            //cancelled code below
                            string model = ddlbrand.SelectedItem.Text.Trim();
                            // decimal unitPrice = Convert.ToDecimal(txtprice.Text.Trim());
                            int availableQuantity = Convert.ToInt32(txtock.Text.Trim());
                            int quantity = Convert.ToInt32(txtassign.Text.Trim());
                            int inserted = 0;
                            //  int availableInventoryQty = AvailableInventoryQty();
                            if (txtassign.Text.Length > 0 && txtock.Text.Length > 0)
                            {
                                double stock = Convert.ToDouble(txtock.Text);
                                double customerqty = Convert.ToDouble(txtassign.Text);
                                double tqty = stock - customerqty;
                                double gqty = tqty;
                                {
                                    {
                                        {
                                            if (stock > 0 && customerqty > 0)
                                            {
                                                using (SqlConnection con = new SqlConnection())
                                                {
                                                    con.ConnectionString = str;
                                                    using (SqlCommand cmd = new SqlCommand())
                                                    {
                                                        cmd.CommandType = CommandType.Text;
                                                        cmd.Connection = con;
                                                        cmd.CommandText = "INSERT INTO Store_Table (Store,Item,Qty,Qty_Remaining) VALUES(@Store,@Item,@Qty,@Qty_Remaining)";
                                                        // cmd.Parameters.AddWithValue("@SellsPerson", HttpContext.Current.User.Identity.Name);
                                                        cmd.Parameters.AddWithValue("@Store", Department.SelectedItem.Text.Trim());
                                                        //  cmd.Parameters.AddWithValue("@Receipt", txtcode.Text.Trim());
                                                        // cmd.Parameters.AddWithValue("@Item", ddlitem.SelectedItem.Text.Trim());
                                                        cmd.Parameters.AddWithValue("@Item", model);
                                                        // cmd.Parameters.AddWithValue("@Price", txtprice.Text.Trim());
                                                        cmd.Parameters.AddWithValue("@Qty", customerqty);
                                                        cmd.Parameters.AddWithValue("@Qty_Remaining", customerqty);
                                                        // cmd.Parameters.AddWithValue("@Sum", txttotalamount.Text.Trim());
                                                        con.Open();
                                                        inserted = cmd.ExecuteNonQuery();
                                                        // txtphone.Text = sdr["Phone"].ToString();
                                                        con.Close();
                                                        //BindGridreport();
                                                    }
                                                }
                                            }
                                            if (availableQuantity >= Convert.ToInt32(quantity))
                                            {
                                                ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Data Submitted Successfully ... !!')", true);
                                            }
                                            else
                                            {
                                                ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('No of Quantity entered is not available in Stock')", true);
                                            }
                                            if (inserted > 0)
                                            {
                                                int updatedStock = availableQuantity - quantity;
                                                using (SqlConnection con = new SqlConnection())
                                                {
                                                    con.ConnectionString = str;
                                                    using (SqlCommand cmd = new SqlCommand())
                                                    {
                                                        cmd.CommandType = CommandType.Text;
                                                        cmd.Connection = con;
                                                        cmd.CommandText = "UPDATE Warehouse_Table SET Stock_Remaining = " + updatedStock + " WHERE Item = '" + model + "'";
                                                        con.Open();
                                                        inserted = cmd.ExecuteNonQuery();
                                                        con.Close();
                                                    }
                                                }
                                            }
                                            // BindProductsSells();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Nov 08, 2021 03:02 AM

Hi micah,

There is no issue in the CreatStock page.

There might be the error in different page.