public DamageItemPage() { InitializeComponent(); DamageItemId.Focus(); ClearDamageGrid(); buttonDelete.Visibility = Visibility.Hidden; }
private void buttonClear_Click(object sender, RoutedEventArgs e) { ClearDamageGrid(); DamageItemId.Focus(); buttonDelete.Visibility = Visibility.Hidden; buttonList.Visibility = Visibility.Visible; buttonSaveDamaged.Visibility = Visibility.Visible; }
private void Window_Loaded(object sender, RoutedEventArgs e) { dt.Columns.Clear(); dt.Columns.Add("DItemNo", typeof(string)); dt.Columns.Add("DName", typeof(string)); dt.Columns.Add("DRate", typeof(double)); dt.Columns.Add("DQuantity", typeof(string)); dt.Columns.Add("DTotal", typeof(double)); dt.Columns.Add("DVid", typeof(string)); dt.Columns.Add("DVname", typeof(string)); dt.Columns.Add("DVphone", typeof(string)); DamageItemId.Focus(); }
private void buttonList_Click(object sender, RoutedEventArgs e) { GetFromDamageStock(); if(dt.Rows.Count<=0) { MessageBox.Show("No Items to List"); } else { buttonDelete.Visibility = Visibility.Visible; buttonList.Visibility = Visibility.Hidden; buttonSaveDamaged.Visibility = Visibility.Hidden; } DamageItemId.Focus(); }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { if (dataGridDamage.SelectedItem != null) { object item = dataGridDamage.SelectedItem; string itemNoString = (dataGridDamage.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text; itemNo = Convert.ToInt32(itemNoString); dt.Rows.RemoveAt(dataGridDamage.SelectedIndex); dataGridDamage.ItemsSource = null; dataGridDamage.ItemsSource = dt.DefaultView; databaseRowDelete(); MessageBox.Show("Item Deleted From Damage Stock"); DamageItemId.Focus(); } else { MessageBox.Show("Please select an item"); } }
private void DamageItemId_PreviewKeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Return) { cc.OpenConnection(); if (cc.BillPreview("select COUNT(*) from Stock where itemid = @value ", "@value", DamageItemId.Text, isExist) > 0) { cc.CloseConnection(); idCount = Convert.ToInt32(DamageItemId.Text); GetFromStock(); if (id.list.Contains(DamageItemId.Text)) { UpdateGridRow(); } else { StoreId(); InsertNewRow(); } DamageItemId.Text = ""; buttonDelete.Visibility = Visibility.Hidden; buttonList.Visibility = Visibility.Visible; buttonSaveDamaged.Visibility = Visibility.Visible; } else { MessageBox.Show("Item does not exist in DB"); DamageItemId.Text = ""; DamageItemId.Focus(); } } } catch (Exception) { if (DamageItemId.Text == "") { MessageBox.Show("Enter Item ID..!"); } } }
private void buttonSaveDamaged_Click(object sender, RoutedEventArgs e) { foreach (DataRow dg in dt.Rows) { string gridId = dg[0].ToString(); string gridName = dg[1].ToString(); string gridRate = dg[2].ToString(); string gridQuantity = dg[3].ToString(); string gridTotal = dg[4].ToString(); string gridVid = dg[5].ToString(); string gridVname = dg[6].ToString(); string gridVphone = dg[7].ToString(); cc.OpenConnection(); cc.ExecuteQuery("insert into DamagedStock(DItemNo,DName,DRate,DQuantity,DTotal,DVid,DVname,DVphone) values('" + gridId + "','" + gridName + "','" + gridRate + "','" + gridQuantity + "','" + gridTotal + "','" + gridVid + "','" + gridVname + "','" + gridVphone + "')"); cc.ExecuteQuery("update Stock set quantity = quantity - " + Convert.ToInt32(gridQuantity) + " where itemid = " + Convert.ToInt32(gridId) + ""); cc.CloseConnection(); } MessageBox.Show("Item Inserted"); ClearDamageGrid(); DamageItemId.Focus(); }