Example #1
0
 private void ItemNumtxt_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         Check_Data();
         ItemNametxt.Focus();
     }
 }
        private void Changes_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            // Calculate Totall Weight and Cost
            int TotallWeightPre = 0;
            int TotallCostPre   = 0;

            if (Convert.ToDouble((e.EditingElement as TextBox).Text) > 0 && Convert.ToDouble((e.EditingElement as TextBox).Text) < 100)
            {
                for (int i = 0; i < BulkItemsDGV.Items.Count; i++)
                {
                    if (e.Row.GetIndex() == i)
                    {
                        DataRowView ToTalItemm = BulkItemsDGV.Items[i] as DataRowView;
                        if (e.Column.Header == "Weight Precentage")
                        {
                            if ((e.EditingElement as TextBox).Text != "")
                            {
                                TotallWeightPre += Convert.ToInt32((e.EditingElement as TextBox).Text);
                            }
                            if (ToTalItemm.Row.ItemArray[4].ToString() != "")
                            {
                                TotallCostPre += Convert.ToInt32(ToTalItemm.Row.ItemArray[4]);
                            }
                        }
                        else
                        {
                            if (ToTalItemm.Row.ItemArray[3].ToString() != "")
                            {
                                TotallWeightPre += Convert.ToInt32(ToTalItemm.Row.ItemArray[3]);
                            }
                            if ((e.EditingElement as TextBox).Text != "")
                            {
                                TotallCostPre += Convert.ToInt32((e.EditingElement as TextBox).Text);
                            }
                        }
                    }
                    else
                    {
                        DataRowView ToTalItemm = BulkItemsDGV.Items[i] as DataRowView;
                        if (ToTalItemm.Row.ItemArray[3].ToString() != "")
                        {
                            TotallWeightPre += Convert.ToInt32(ToTalItemm.Row.ItemArray[3]);
                        }
                        if (ToTalItemm.Row.ItemArray[4].ToString() != "")
                        {
                            TotallCostPre += Convert.ToInt32(ToTalItemm.Row.ItemArray[4]);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please check The Value at Item " + "'" + ((DataRowView)BulkItemsDGV.Items[e.Row.GetIndex()]).Row.ItemArray[2] + "'" + " that you Entered  That Must be Between 0 To 100");
            }
            ItemNametxt.Focus();
            WaisWeightttxt.Text = TotallWeightPre.ToString();
            WaistCosttxt.Text   = TotallCostPre.ToString();
        }