Example #1
0
 private void TxtGridStartNo_Validating(object sender, CancelEventArgs e)
 {
     if (Tag == "" || ActiveControl == TxtGridStartNo)
     {
         return;
     }
     if (Grid["Waiter", 0].Value == null)
     {
         return;
     }
     if (!string.IsNullOrEmpty(TxtGridWaiter.Text) && string.IsNullOrEmpty(TxtGridStartNo.Text))
     {
         MessageBox.Show("KOT start number cannot left blank ...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtGridStartNo.Focus();
         return;
     }
     else
     {
         if (Grid.Rows.Count > 1)
         {
             for (int i = 1; i < Grid.Rows.Count; i++)
             {
                 if (Convert.ToDecimal(TxtGridStartNo.Text) >= Convert.ToDecimal(Grid["StartNo", i - 1].Value.ToString()) && Convert.ToDecimal(TxtGridStartNo.Text) <= Convert.ToDecimal(Grid["EndNo", i - 1].Value.ToString()))
                 {
                     MessageBox.Show("'" + TxtGridStartNo.Text + "' KOT number is already assign to another waiter '" + Grid["Waiter", i - 1].Value.ToString() + "'...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     TxtGridStartNo.Focus();
                     return;
                 }
             }
         }
     }
 }
Example #2
0
 private void TxtGridEndNo_Validating(object sender, CancelEventArgs e)
 {
     if (Tag == "" || ActiveControl == TxtGridEndNo)
     {
         return;
     }
     if (TxtGridWaiter.Text == "")
     {
         return;
     }
     decimal.TryParse(TxtGridStartNo.Text, out decimal startno);
     decimal.TryParse(TxtGridEndNo.Text, out decimal endno);
     if (!string.IsNullOrEmpty(TxtGridWaiter.Text) && string.IsNullOrEmpty(TxtGridEndNo.Text))
     {
         MessageBox.Show("KOT End number cannot left blank ...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtGridEndNo.Focus();
         return;
     }
     else if (Grid.Rows.Count > 1)
     {
         for (int i = 1; i < Grid.Rows.Count; i++)
         {
             if (endno <= Convert.ToDecimal(Grid["EndNo", i - 1].Value.ToString()) && endno >= Convert.ToDecimal(Grid["StartNo", i - 1].Value.ToString()))
             {
                 MessageBox.Show("'" + TxtGridEndNo.Text + "' KOT number is already assign to another waiter  '" + Grid["Waiter", i - 1].Value.ToString() + "'...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 TxtGridEndNo.Focus();
                 return;
             }
         }
     }
     else
     {
         if (endno <= startno)
         {
             MessageBox.Show("KOT end number should be greater then start number...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
             TxtGridEndNo.Focus();
             return;
         }
     }
     if (SetTextBoxValueToGrid() == true)
     {
         if (Grid.CurrentRow.Index == (Grid.Rows.Count - 1))
         {
             Grid.Rows.Add();
             Grid.CurrentCell = Grid.Rows[Grid.Rows.Count - 1].Cells["Waiter"];
         }
         else
         {
             Grid.CurrentCell = Grid.Rows[Grid.CurrentRow.Index + 1].Cells["Waiter"];
         }
     }
     _GridControlMode = false;
     GridControlMode(false);
     _GridControlMode = true;
     Grid.Focus();
 }
Example #3
0
        private void GridControlMode(bool mode)
        {
            if (Grid.CurrentRow != null)
            {
                int currRo   = Grid.CurrentRow.Index;
                int colindex = 0;
                if (mode == true)
                {
                    colindex = Grid.Columns["TermRate"].Index;
                    TxtGridRatePercent.Size     = this.Grid.GetCellDisplayRectangle(colindex, currRo, true).Size;
                    TxtGridRatePercent.Location = this.Grid.GetCellDisplayRectangle(colindex, currRo, true).Location;

                    colindex               = Grid.Columns["Amount"].Index;
                    TxtGridAmount.Size     = this.Grid.GetCellDisplayRectangle(colindex, currRo, true).Size;
                    TxtGridAmount.Location = this.Grid.GetCellDisplayRectangle(colindex, currRo, true).Location;
                }
                SetGridValueToTextBox(currRo);
            }

            TxtGridRatePercent.Enabled = mode;
            TxtGridRatePercent.Visible = mode;

            TxtGridAmount.Enabled = mode;
            TxtGridAmount.Visible = mode;

            if (mode == true)
            {
                TxtGridRatePercent.Focus();
            }
        }
Example #4
0
 private void TxtGridUsedNo_Validating(object sender, CancelEventArgs e)
 {
     if (Tag == "" || ActiveControl == TxtGridUsedNo)
     {
         return;
     }
     if ((string.IsNullOrEmpty(TxtGridUsedNo.Text) ? false : Convert.ToInt32(TxtGridUsedNo.Text) > 0))
     {
         if ((Convert.ToInt32(TxtGridUsedNo.Text) < Convert.ToInt32(TxtGridStartNo.Text) ? true : Convert.ToInt32(this.TxtGridUsedNo.Text) > Convert.ToInt32(TxtGridEndNo.Text)))
         {
             MessageBox.Show("Used Number must be between Start number and End Number.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             TxtGridUsedNo.Focus();
             return;
         }
     }
     if (SetTextBoxValueToGrid())
     {
         if (Grid.CurrentRow.Index != Grid.Rows.Count - 1)
         {
             Grid.CurrentCell = Grid.Rows[Grid.CurrentRow.Index + 1].Cells["UsedNo"];
         }
         else
         {
             Grid.Rows.Add();
             Grid.CurrentCell = Grid.Rows[Grid.Rows.Count - 1].Cells["Waiter"];
         }
         //if ((Grid.Rows[Grid.Rows.Count - 1].Cells["Waiter"].Value == null ? false : Grid.Rows[Grid.Rows.Count - 1].Cells["Waiter"].Value != null))
         //{
         //    GridControlMode(true);
         //}
         //else
         //{
         GridControlMode(true);
         //}
     }
 }
Example #5
0
        private void TxtGridQty_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            decimal.TryParse(TxtGridQty.Text, out decimal _Qty);
            if (_Qty <= 0)
            {
                TxtGridQty.Focus();
                return;
            }
            decimal _convRatio = TxtGridParticular.AltConversion;

            if (ClsGlobal.InventoryAltQtyConversion == "Y" && TxtGridAltQty.Enabled == true && Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) > 0 && _convRatio > 0)
            {
                TxtGridAltQty.Text = ClsGlobal.DecimalFormate((Convert.ToDecimal(string.IsNullOrEmpty(TxtGridQty.Text) ? "0" : TxtGridQty.Text) / Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) * _convRatio), 1, ClsGlobal._QtyDecimalFormat).ToString();
            }
        }
Example #6
0
        private void TxtGridRatePercent_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            int     indx        = Grid.CurrentRow.Index;
            decimal totalRecAmt = 0;
            int     i           = 0;

            decimal.TryParse(TxtGridRatePercent.Text, out decimal output);
            TxtGridRatePercent.Text = ClsGlobal.DecimalFormate(output, 1, ClsGlobal._AmountDecimalFormat).ToString();

            decimal percent = Convert.ToDecimal(Grid[7, indx].Value.ToString());

            if (output <= 0 && Convert.ToDecimal(TxtGridAmount.Text) <= 0)
            {
                TxtGridAmount.Text = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString();
            }
            else if (output <= 0 && percent > 0)
            {
                TxtGridAmount.Text = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString();
            }

            totalRecAmt = Convert.ToDecimal(TxtBasicAmount.Text);

            if (!string.IsNullOrEmpty(_ExistTermData))
            {
                string[] val1         = _ExistTermData.Split('|');
                string   ratepercent1 = val1[2];
                arrRatepercent1 = ratepercent1.Split(',');
            }

            foreach (DataGridViewRow ro in Grid.Rows)
            {
                if (indx == i)
                {
                    if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() == "V")
                    {
                        string formula = ro.Cells["Formula"].Value.ToString();
                        if (output > 0)
                        {
                            if (string.IsNullOrEmpty(formula))
                            {
                                TxtGridAmount.Text = ClsGlobal.DecimalFormate(((totalRecAmt / 100) * output), 1, ClsGlobal._AmountDecimalFormat).ToString();
                            }
                            else
                            {
                                DataTable GridTable = ClsGlobal.GridToDataTable(Grid);
                                DataTable myTable   = new DataTable();
                                myTable            = GridTable.Clone();
                                totalRecAmt        = CalBasicAmt4Formula(formula, GridTable, myTable);
                                TxtGridAmount.Text = ClsGlobal.DecimalFormate((totalRecAmt / 100 * output), 1, ClsGlobal._AmountDecimalFormat).ToString();
                            }
                        }

                        myGridTxtAmt = TxtGridAmount.Text;
                        SetTextBoxValueToGrid();
                    }
                    else if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() == "Q")
                    {
                        if (output > 0)
                        {
                            TxtGridAmount.Text = ClsGlobal.DecimalFormate((_Qty * output), 1, ClsGlobal._AmountDecimalFormat).ToString();
                        }

                        myGridTxtAmt = TxtGridAmount.Text;
                        SetTextBoxValueToGrid();
                    }

                    TxtGridAmount.Focus();

                    decimal.TryParse(TxtGridAmount.Text, out decimal txtBoxGridAmount);

                    if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() != "R")
                    {
                        CalTermAmount(indx, txtBoxGridAmount, "P");
                    }
                    return;
                }
                else
                {
                    if (ro.Cells["Amount"].Value != null)
                    {
                        string sign = ro.Cells["Sign"].Value.ToString();
                        decimal.TryParse(ro.Cells["Amount"].Value.ToString(), out decimal val);

                        if (sign.Trim() == "-")
                        {
                            totalRecAmt += -val;
                        }
                        else
                        {
                            totalRecAmt += +val;
                        }
                    }
                }
                i++;
            }
        }