private void btnEditCategory_Click(object sender, EventArgs e) { var selectedRows = gvProductCategory.SelectedRows.ToArray(); if (selectedRows.Length == 0) { MessageBox.Show("خطا! ابتدا یک مورد را برای ویرایش انتخاب کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { btnEditCategory.Enabled = true; for (int i = 0; i < selectedRows.Length; i++) { int id = Convert.ToInt32(gvProductCategory.SelectedRows[i].Cells[0].Value); //int categoryCode = Convert.ToInt32(gvProductCategory.SelectedRows[i].Cells[1].Value); DialogResult dialogResult = MessageBox.Show(string.Format("آیا میخواهید کد {0} ویرایش شود؟", id), "اخطار", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dialogResult == DialogResult.OK) { Ref_ProductCategoryViewModel.Edit(id, txtCategoryName.Text); MessageBox.Show(string.Format("کد {0} تغییر یافت", id), "موفق", MessageBoxButtons.OK, MessageBoxIcon.Information); } } // this.productCategoryTableAdapter.Fill(onlineShopDataSet1.ProductCategory); gvProductCategory.DataSource = Ref_ProductCategoryViewModel.FillGrid(); } }
private void btnSaveCategory_Click(object sender, EventArgs e) { if (txtCategoryName.Text != "") { Ref_ProductCategoryViewModel.Save(txtCategoryName.Text); MessageBox.Show(string.Format(".گروه کالای جدید ذخیره شد"), "موفق", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.productCategoryTableAdapter.Fill(onlineShopDataSet1.ProductCategory); gvProductCategory.DataSource = Ref_ProductCategoryViewModel.FillGrid(); foreach (Telerik.WinControls.UI.GridViewRowInfo item in gvProductCategory.Rows) { if (item.Index == gvProductCategory.RowCount - 1) { item.IsSelected = true; } } txtCategoryName.Text = " "; } else { MessageBox.Show("خطا! ابتدا نام گروه کالا را مشخص کنید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRefreshCategory_Click(object sender, EventArgs e) { //DataTable ProductCategory = new DataTable(); //ProductCategory = Ref_ProductCategoryViewModel.FillGrid(); //foreach (DataRow row in ProductCategory.Rows) //{ // gvProductCategory.Rows.Add(row.ItemArray); //} gvProductCategory.DataSource = Ref_ProductCategoryViewModel.FillGrid(); }