private void SaveWeeklyPhysicalStk_Load(object sender, EventArgs e) { try { LoadGrid(); BtnProperty(); TxtPhysicalStock.Focus(); LBLAvalable_Stock.Text = "Avalable Fuel Stock: " + weeklyStock.FuelSystemStock().ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void DgvFuelStock_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { //DataGridViewCellEventArgs e1=new DataGridViewCellEventArgs(e) if (Properties.Settings.Default.LastUser.ToLower() != "admin") { MessageBox.Show("You are not allow to delete", "Weekly physical Stock", MessageBoxButtons.OK, MessageBoxIcon.Hand); LoadGrid(); } else if (Properties.Settings.Default.LastUser.ToLower() == "admin") { DialogResult usersChoice = MessageBox.Show(@"You are about to delete " + DgvFuelStock.SelectedRows.Count + " Row(s).\n\n \r Click Yes to permanently delete these rows. You won’t be able to undo these changes.", "Fuel Physical Stock", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); // cancel the delete event if (usersChoice == DialogResult.No) { e.Cancel = true; } else if (usersChoice == DialogResult.Yes) { int id = Convert.ToInt32(DgvFuelStock.Rows[0].Cells[0].Value); //int id=DgvFuelStock.SelectedCells[0].RowIndex.Cells[0].Value.ToString(); object val = DgvFuelStock.SelectedRows[0].Cells[0].Value; int value = Convert.ToInt32(val); if (weeklyStock.DeleteFromWeeklyStock(value)) { MessageBox.Show("Record has been deleted"); TxtPhysicalStock.Clear(); TxtPhysicalStock.Focus(); } } } }
public SaveWeeklyPhysicalStk() { InitializeComponent(); ToolTipShow(); TxtPhysicalStock.Focus(); }