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(); } } } }
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 BtnSave_Click(object sender, EventArgs e) { try { DataTable dtWeekly = weeklyStock.GetWeekName(); DataRow drWeekly = dtWeekly.Rows[0]; //string week = drWeekly[0].ToString();//Get week name string date = drWeekly[1].ToString(); //get current date if (weeklyStock.GetLastDatWeeklyStk() != date) //check fo db date with current date { //Adding operation DialogResult usersChoice = MessageBox.Show(@"Do you want to save the value " + TxtPhysicalStock.Text.ToString() + ".\n \n\r Click 'Yes' to save the value.", "Fuel Physical Stock", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (usersChoice == DialogResult.Yes) { if (weeklyStock.AddToWeeklyStockTb(Convert.ToDouble(TxtPhysicalStock.Text), Convert.ToDouble(TxtMeterCount.Text))) { LoadGrid(); MessageBox.Show("Sucessfully Add the Weekly stock Table....!", "Weekly physical Stock", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Something is wrong.....!", "Error with adding details", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { TxtPhysicalStock.Clear(); } } else { MessageBox.Show(date.Substring(3, 2) + "/" + date.Substring(0, 2) + "/" + date.Substring(6, 4) + " Date physical stock is alredy exsist.....!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } catch (Exception ex) { MessageBox.Show("Check the input\n\n" + ex.Message.ToString(), "Error in Btn Save Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public SaveWeeklyPhysicalStk() { InitializeComponent(); ToolTipShow(); TxtPhysicalStock.Focus(); }