private void dataGrid2_CellEditEnding(object sender, Microsoft.Windows.Controls.DataGridCellEditEndingEventArgs e)
        {
            if (e.Row.Item != null)
            {
                CommonResource.HomeAndQuantity result = e.Row.Item as CommonResource.HomeAndQuantity;
                TextBox t        = e.EditingElement as TextBox;
                decimal quantity = 1;
                bool    ok       = true;
                string  message  = "";

                try
                {
                    quantity = decimal.Parse(t.Text);
                }
                catch (Exception ex)
                {
                    message = "Please enter a valid quantity!";
                    ok      = false;
                }


                if (ok)
                {
                    if (quantity != result.Quantity)
                    {
                        cr.UpdateQuantityAtHomeFacade(cmbArea.SelectedValue.ToString(), cmbGroup.SelectedValue.ToString(), result.HomeID.ToString(), quantity.ToString(), usercode);
                    }
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }
        private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                CommonResource.retrunValue rv = (CommonResource.retrunValue)e.Result;
                DataSet ds       = rv.HomeModelSet;
                DataSet facadeds = rv.FacadeSet;
                List <CommonResource.HomeModelAndQuantity> HomeModelQty = new List <CommonResource.HomeModelAndQuantity>();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    List <CommonResource.HomeAndQuantity> hl = new List <CommonResource.HomeAndQuantity>();
                    CommonResource.HomeModelAndQuantity   hq = new CommonResource.HomeModelAndQuantity();
                    hq.HomeModel       = dr["homemodel"].ToString();
                    hq.Quantity        = decimal.Parse(dr["quantity"].ToString());
                    hq.UpdatedQuantity = decimal.Parse(dr["quantity"].ToString());
                    if ((dr["multipleqty"].ToString().ToUpper() == "1" || dr["multipleqty"].ToString().ToUpper() == "TRUE"))
                    {
                        hq.MultipleQuantity = true;
                    }
                    else
                    {
                        hq.MultipleQuantity = false;
                    }

                    hq.Display1 = dr["Display1"].ToString();
                    hq.Display2 = dr["Display2"].ToString();
                    hq.Display3 = dr["Display3"].ToString();
                    hq.Display4 = dr["Display4"].ToString();
                    hq.Display5 = dr["Display5"].ToString();
                    hq.Display6 = dr["Display6"].ToString();
                    hq.BMPImage = dr["warningimage"].ToString();

                    foreach (DataRow dr2 in facadeds.Tables[0].Rows)
                    {
                        if (dr2["homemodel"].ToString() == hq.HomeModel)
                        {
                            CommonResource.HomeAndQuantity hh = new CommonResource.HomeAndQuantity();
                            hh.HomeID          = int.Parse(dr2["homeid"].ToString());
                            hh.HomeName        = dr2["homemodel"].ToString() + " " + dr2["facade"].ToString();
                            hh.Quantity        = decimal.Parse(dr2["quantity"].ToString());
                            hh.UpdatedQuantity = decimal.Parse(dr2["quantity"].ToString());
                            //if (dr2["allowedit"].ToString() == "1" || dr2["allowedit"].ToString().ToUpper() == "TURE")
                            //{
                            //    hh.Enabled = true;
                            //}
                            //else
                            //{
                            //    hh.Enabled = false;
                            //}

                            hl.Add(hh);
                        }
                    }
                    hq.HomeList = hl;
                    HomeModelQty.Add(hq);
                }
                dataGrid1.DataContext = HomeModelQty;
            }
            imagebox.Visibility = Visibility.Collapsed;
        }