private void saveBtn_Click(object sender, EventArgs e)
        {
            //   var q = bl.First(a => a.id == dd.sillingBillId);
            if (Convert.ToInt32(quntInput.Value) > 0 && nameText.SelectedIndex > -1 && userText.SelectedIndex > -1 && billText.SelectedIndex > -1)
            {
                DeadProductDto dd = new DeadProductDto();

                dd.sillingBillId = Convert.ToInt32(billText.Text.ToString().Trim());

                dd.name        = nameText.Text.Trim();
                dd.quntity     = Convert.ToInt32(quntInput.Value);
                dd.processDate = dateText.Value;
                dd.user_name   = userText.Text.Trim();
                dd.note        = noteText.Text;
                int res = dpdal.createDeadProduct(dd);
                if (res == 1)
                {
                    MessageBox.Show("تم اضافة المنتج للمرتجعات");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("حدث خطأ  ", "رسالة", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("ادخل البيانات بشكل صحيح ");
            }
        }
        //select all dead product
        public List <DeadProductDto> getAllDeadProducts()
        {
            List <DeadProductDto> li = new List <DeadProductDto>();

            try
            {
                List <Dead_Products> l = db.Dead_Products.ToList();
                foreach (var i in l)
                {
                    DeadProductDto ddto = new DeadProductDto();
                    ddto.id            = i.id;
                    ddto.name          = pdal.getProductNameById(i.product_id);
                    ddto.note          = i.note;
                    ddto.quntity       = (int)i.quantity;
                    ddto.user_name     = user.getUserNameById((int)i.user_id);
                    ddto.processDate   = i.process_date;
                    ddto.sillingBillId = (int)i.bill_id;

                    li.Add(ddto);
                }
                return(li);
            }
            catch (Exception e)
            {
                MessageBox.Show("error happend " + e.Message);
                return(null);
            }
        }
        //create dead product
        public int createDeadProduct(DeadProductDto dead)
        {
            Dead_Products d = new Dead_Products();

            d.bill_id      = dead.sillingBillId;
            d.note         = dead.note;
            d.quantity     = dead.quntity;
            d.user_id      = user.getUserIdByName(dead.user_name.Trim());
            d.product_id   = pdal.getProductIdByName(dead.name.Trim());
            d.process_date = dead.processDate;
            Selling_Bill_Details billDetails = sdal.getBillDetailsByBillId(dead.sillingBillId, d.product_id);
            Selling_Bill         bil         = sdal.getSellingBillByid(dead.sillingBillId);
            Customer             cu          = cdal.getCustomerById(bil.cust_id);

            //to do edit bill and client balance
            try
            {
                // MessageBox.Show(bil.cust_id + " " + cu.cust_id);
                if (d.quantity <= billDetails.product_quantity)
                {
                    Product p = pdal.getProductById(dead.name.Trim());
                    p.product_quantity += dead.quntity;

                    billDetails.product_quantity -= dead.quntity;
                    // billDetails.product_price -= dead.quntity * p.product_price;
                    bil.total -= dead.quntity * (billDetails.product_price - billDetails.profuct_discount);

                    cu.cust_balance -= dead.quntity * (billDetails.product_price - billDetails.profuct_discount);
                    cdal.updateCutomer(cu);
                    sdal.updateSellingBil(bil);
                    sdal.updateSellingBillDetails(billDetails);
                    pdal.updateProduct(p);
                    db.Dead_Products.Add(d);
                    db.SaveChanges();
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(0);
            }
        }
 //update dead product
 public int updateDeadProduct(DeadProductDto dead)
 {
     return(0);
 }