private void brproductlist_SelectedIndexChanged(object sender, EventArgs e)
 {
     ServiceStock.StockData s = sdata.FirstOrDefault(m => m.Id == stockid[brproductlist.SelectedIndex]);
     if (s != null)
     {
         Quntityindicator.Text = "< " + s.Available;
     }
     else
     {
         Quntityindicator.Text = "00";
     }
 }
        private void brStockdata_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DialogResult r = CustomMessage.Show("Operation", "Select Edit or Delete", "Edit", "Delete", "Cancel");

            if (r == DialogResult.Yes)
            {
                DataGridViewRow row = new DataGridViewRow();
                row         = brStockdata.Rows[e.RowIndex];
                s.Id        = Int32.Parse(row.Cells["Id"].Value.ToString());
                s.Name      = row.Cells["Name"].Value.ToString();
                s.Quantity  = Int32.Parse(row.Cells["Quantity"].Value.ToString());
                s.Price     = Int32.Parse(row.Cells["Price"].Value.ToString());
                s.DOM       = (System.DateTime)row.Cells["DOM"].Value;
                s.Available = Int32.Parse(row.Cells["Available"].Value.ToString());
                s.Branch_Id = Int32.Parse(row.Cells["Branch_Id"].Value.ToString());

                editName.Text                = s.Name;
                editQuntity.Text             = s.Quantity + "";
                editAvailable.Text           = s.Available + "";
                editPrice.Text               = s.Price + "";
                editDOM.Value                = s.DOM;
                editBranchList.SelectedIndex = Br_Id.IndexOf(s.Branch_Id);
                Edit.BringToFront();
            }
            else if (r == DialogResult.No)
            {
                DataGridViewRow row = brStockdata.Rows[e.RowIndex];



                ServiceStock.StockData data = new ServiceStock.StockData();
                data = ss.deleteStock(Int32.Parse(row.Cells["Id"].Value.ToString()));

                if (data != null)
                {
                    MessageBox.Show("Deleted successfully", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    load_data();
                }
            }
            else
            {
            }
        }
        private void addtobill_Click(object sender, EventArgs e)
        {
            ServiceStock.StockData s = new ServiceStock.StockData();
            s = sdata.FirstOrDefault(m => m.Id == stockid[brproductlist.SelectedIndex]);
            ServiceSale.Sale row = new ServiceSale.Sale();
            row.Quantity = Int32.Parse(productquntity.Text);
            row.Stock_ID = stockid[brproductlist.SelectedIndex];
            row.Total    = row.Quantity * s.Price;
            saledata.Add(row);
            billgrid b = new billgrid();

            b.Name     = s.Name;
            b.Quantity = row.Quantity;
            b.Stockid  = row.Stock_ID;
            b.Price    = s.Price;
            b.Total    = (int)row.Total;
            billsitem.Add(b);

            load_sale();
        }
 private void editStockbtn_Click(object sender, EventArgs e)
 {
     s.Name      = editName.Text;
     s.Quantity  = Int32.Parse(editQuntity.Text);
     s.Available = Int32.Parse(editAvailable.Text);
     s.Price     = Int32.Parse(editPrice.Text);
     s.DOM       = editDOM.Value;
     s.Branch_Id = Br_Id[editBranchList.SelectedIndex];
     ServiceStock.StockData data = new ServiceStock.StockData();
     data = ss.updateStock(s);
     if (data != null)
     {
         selectbranch.Text = "";
         MessageBox.Show("Edit Successfully", "Edit", MessageBoxButtons.OK, MessageBoxIcon.Information);
         load_data();
         All.BringToFront();
     }
     else
     {
         MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }