コード例 #1
0
        private void dgvGroup_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            currentDiscountCell = (sender as DataGridView).Rows[e.RowIndex].Cells["discountName"];
            currentRow          = discounts.FindBydiscountId((int)(sender as DataGridView).Rows[e.RowIndex].Cells["discountId"].Value);
            tbxDiscount.Text    = (sender as DataGridView).Rows[e.RowIndex].Cells["discountName"].Value.ToString();

            vdisDa.Fill(DBclass.DS.v_discount, currentRow.discountId);


            var dgv = sender as DataGridView;

            if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
            {
                switch (dgv.Name)
                {
                case "dgvGroup":
                    switch (dgv.Columns[e.ColumnIndex].Name)
                    {
                    case "colBtn":
                        ProdList prodlist = new ProdList();
                        if (prodlist.ShowDialog() == DialogResult.OK)
                        {
                            DataSetTpos.v_discountRow[] vDisRow = (DataSetTpos.v_discountRow[])DBclass.DS.v_discount.Select("productId" + prodlist.id);
                            if (vDisRow.Length > 0 || vDisRow[0].discountId != currentRow.discountId)
                            {
                                DataSetTpos.discountproductsRow dpr = discountpr.NewdiscountproductsRow();
                                dpr.discount   = 0;
                                dpr.productId  = Convert.ToInt32(prodlist.id);
                                dpr.discountId = currentRow.discountId;
                                discountpr.AdddiscountproductsRow(dpr);
                                discountpDa.Update(discountpr);

                                vdisDa.Fill(DBclass.DS.v_discount, currentRow.discountId);
                            }
                        }

                        break;

                    case "colBtnDel":
                        if (MessageBox.Show("Вы действительно хотите удалить группу скидок?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            discountpDa.DeleteDiscount(currentRow.discountId);
                            currentRow.Delete();

                            discountDA.Update(currentRow);

                            if (discounts.Rows.Count > 0)
                            {
                                dgv.Rows[0].Cells["discountName"].Selected = true;
                                dgvGroup_CellClick(dgv, new DataGridViewCellEventArgs(1, 0));
                            }
                        }

                        break;
                    }

                    break;
                }
            }
        }
コード例 #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     DataSetTpos.discountsRow disRow = discounts.NewdiscountsRow();
     disRow.discountName = tbxDiscount.Text;
     disRow.barcode      = Classes.Generator.barcode_generate(8, 8);
     disRow.percent      = 0;
     discounts.AdddiscountsRow(disRow);
     discountDA.Update(disRow);
 }
コード例 #3
0
 private void Discounts_TableNewRow(object sender, DataTableNewRowEventArgs e)
 {
     DataSetTpos.discountsRow disRow = e.Row as DataSetTpos.discountsRow;
     disRow.barcode = Classes.Generator.barcode_generate(8, 8);
     disRow.percent = 0;
 }