//เหตการณหลังจากคลิกเลือก Context menu เป็น "แก้ไข"
        private void itemedit_Click(object sender, EventArgs e)
        {
            if (LvDetail.SelectedItems.Count == 0) return;
            ///////Load Detail
            String ProductId = LvDetail.SelectedItems[0].SubItems[0].Text;
            String ProductName = LvDetail.SelectedItems[0].SubItems[1].Text;
            String SaleAppDetailQuantityPack = LvDetail.SelectedItems[0].SubItems[2].Text;
            String UnitPackName = LvDetail.SelectedItems[0].SubItems[3].Text;
            String SaleAppDetailQuantity = LvDetail.SelectedItems[0].SubItems[4].Text;
            String UnitSaleName = LvDetail.SelectedItems[0].SubItems[5].Text;
            String SaleAppDetailWeight = LvDetail.SelectedItems[0].SubItems[6].Text;
            String ProductAppType = LvDetail.SelectedItems[0].SubItems[7].Text;
            String Note = LvDetail.SelectedItems[0].SubItems[8].Text;
            string[] Detail = new string[] { ProductId, ProductName, SaleAppDetailQuantityPack, UnitPackName, SaleAppDetailQuantity, UnitSaleName, SaleAppDetailWeight, ProductAppType, Note };
            ///////Load Weight
            ArrayList Weight = new ArrayList();
            int row = DataWeight.Count;
            for (int i = 0; i < row; i++)
            {
                string[] str = (string[])DataWeight[i];
                String productId = str[0];
                if (productId == ProductId)
                {
                    String SaleAppWeight = str[1];
                    String SaleAppPack = str[2];
                    String SaleAppPackId = str[3];
                    Weight.Add(new string[] { SaleAppWeight, SaleAppPack, SaleAppPackId });
                }
            }
            ///////Type Sale
            int typeSale = Convert.ToInt16(ProductAppType);

            DialogAppSaleManage d = new DialogAppSaleManage(Detail, Weight, typeSale);
            d.ShowDialog();
            if (d.DialogResult == DialogResult.OK)
            {
                //  Update  Detail //
                String ProductId_new = d.TbxProductId.Text;
                ProductName = d.TbxProductName.Text;
                SaleAppDetailQuantityPack = d.TbxSaleAppDetailQuantityPack.Text;
                UnitPackName = d.LbUnitPackName.Text;
                SaleAppDetailQuantity = d.TbxSaleAppDetailQuantity.Text;
                UnitSaleName = d.LbUnitSaleName.Text;
                SaleAppDetailWeight = d.TbxSaleAppDetailWeight.Text;
                Note = d.TbxNote.Text;
                Detail = new string[] { ProductId_new, ProductName, SaleAppDetailQuantityPack, UnitPackName, SaleAppDetailQuantity, UnitSaleName, SaleAppDetailWeight, ProductAppType, Note };
                UpdateDetail(ProductId, Detail);

                //  Update  Weight //
                DeleteWeight(ProductId);
                int d_row = d.gvWeightCountRow;

                List<string> SaleAppPackId = d.InterPackId();
                List<string> SaleAppPack = d.InterPack();
                List<string> SaleAppWeight = d.InterWeight();

                for (int i = 0; i < SaleAppWeight.Count; i++)
                {
                    string[] str = new string[] { ProductId_new, SaleAppWeight[i], SaleAppPack[i], SaleAppPackId[i] };
                    AddWeight(str);
                }
                ShowLvDetail();
                ShowLvWeight(ProductId_new);
            }
        }
        //เหตการณืหลังจากคลิกปุ่ม BtnSelectOK หลังจากเลือกรูปแบบการเพิ่มสินค้าใหม่
        private void BtnSelectOK_Click(object sender, EventArgs e)
        {
            String ProductId = TbxProductId.Text;
            String ProductName = TbxProductName.Text;
            int SaleType = (RadioWeightQuantity.Checked) ? 0 : (RadioQuantity.Checked) ? 1 : 2;
            DialogAppSaleManage d = new DialogAppSaleManage(ProductId, SaleType, Conn);
            d.ShowDialog();
            if (d.DialogResult == DialogResult.OK)
            {
                //  Add  Detail //
                String ProductId_new = d.TbxProductId.Text;
                String ProductName_new = d.TbxProductName.Text;
                String SaleAppDetailQuantityPack = d.TbxSaleAppDetailQuantityPack.Text;
                String UnitPackName = d.LbUnitPackName.Text;
                String SaleAppDetailQuantity = d.TbxSaleAppDetailQuantity.Text;
                String UnitSaleName = d.LbUnitSaleName.Text;
                String SaleAppDetailWeight = d.TbxSaleAppDetailWeight.Text;
                String Note = d.TbxNote.Text;
                string[] Detail = new string[] { ProductId_new, ProductName_new, SaleAppDetailQuantityPack, UnitPackName, SaleAppDetailQuantity, UnitSaleName, SaleAppDetailWeight, SaleType + "", Note };
                AddDetail(Detail);

                //  Add  Weight //
                int d_row = d.gvWeightCountRow - 1;

                List<string> SaleAppPackId = d.InterPackId();
                List<string> SaleAppPack = d.InterPack();
                List<string> SaleAppWeight = d.InterWeight();

                for (int i = 0; i < d_row; i++)
                {
                    string[] str = new string[] { };
                    if (SaleAppWeight.Count != 0)
                    {
                        str = new string[] { ProductId_new, SaleAppWeight[i], SaleAppPack[i], SaleAppPackId[i] };
                    }
                    else
                    {
                        str = new string[] { ProductId_new, SaleAppPack[i], SaleAppPackId[i] };
                    }

                    AddWeight(str);
                }
                TbxProductId.Text = "";
                TbxProductName.Text = "";
                TbxProductId.Focus();
                ShowLvDetail();
                ShowLvWeight(ProductId_new);
            }

            RadioWeightQuantity.Checked = true;
            PnlSelectType.Visible = false;
        }