Exemple #1
0
        private void TextBoxGroupID_Leave(object sender, EventArgs e)
        {
            try
            {
                bool Exsists = false;
                if (_TypeOperation == ClassPublicVar.TypeOperation.Add)
                {
                    DTGroupID = _ClassSelect.SelectOpration(new string[] { TableTypeAcc.ID, TableTypeAcc.GroupName, TableTypeAcc.NameLng1, TableTypeAcc.IsGroup }, "TableTypeAcc");

                    if (TextBoxGroupID.Text == "")
                    {
                    }
                    else if (TextBoxGroupID.Text == "0")
                    {
                        TextBoxGroupID.Text   = "0";
                        TextBoxGroupName.Text = "Root";
                    }
                    else
                    {
                        foreach (DataRow row in DTGroupID.Rows)
                        {
                            if (row[TableTypeAcc.ID].ToString() == TextBoxGroupID.Text)
                            {
                                if (row[TableTypeAcc.IsGroup].ToString() == "0")
                                {
                                    MessageBox.Show("لا يمكن الإضافة لفرد");
                                    TextBoxGroupID.Focus();
                                    TextBoxGroupID.Clear();
                                    Exsists = true;
                                }

                                else
                                {
                                    TextBoxGroupID.Text   = row[TableTypeAcc.ID].ToString();
                                    TextBoxGroupName.Text = row[TableTypeAcc.NameLng1].ToString();
                                    TextBoxNameLng1.Focus();
                                    Exsists = true;
                                    break;
                                }
                            }
                        }


                        if (Exsists == false)
                        {
                            MessageBox.Show("غير موجود");
                            TextBoxGroupID.Clear();
                            DTGroupID.Clear();
                            TextBoxGroupID.Focus();
                            buttonGroupSearch_Click(sender, e);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void TextBoxGroupID_Leave(object sender, EventArgs e)
        {
            try
            {
                bool Exsists = false;

                if (_TypeOperation == ClassPublicVar.TypeOperation.Add)
                {
                    //DTGroupID = _ClassSelect.SelectOpration(new string[] { TableCostCenter.ID, TableCostCenter.GroupName , TableCostCenter.NameLng1 , TableCostCenter.IsGroup}, "TableCostCenter", new string[] { TableCostCenter.ID }, new string[] { TextBoxGroupID.Text });
                    DTGroupID = _ClassSelect.SelectOpration(new string[] { TableCostCenter.ID, TableCostCenter.GroupName, TableCostCenter.NameLng1, TableCostCenter.IsGroup }, "TableCostCenter");

                    //[TableCostCenter.ID].ToString()
                    //if (DTGroupID.Rows[0][TableCostCenter.ID] == DBNull.Value)
                    //if ( DBNull.Value.Equals(DTGroupID.Rows.Count>0))
                    //{
                    //    MessageBox.Show("غير موجود");
                    //    TextBoxGroupID.Focus();
                    //}

                    //foreach (DataRow row in DTGroupID.Rows)
                    //{
                    //object sss = row[TableCostCenter.ID];
                    //    if ( sss == DBNull.Value )
                    //    {
                    //        MessageBox.Show("غير موجود");
                    //        TextBoxID.Focus();
                    //        break;
                    //    }
                    //}

                    //if (DTGroupID.Rows[0][TableCostCenter.ID].ToString() == "")
                    //{
                    //    MessageBox.Show("غير موجود");
                    //    TextBoxGroupID.Focus();
                    //}

                    //if (DTGroupID.Rows.Count < 0)
                    //{
                    //    MessageBox.Show("غير موجود");
                    //    TextBoxGroupID.Focus();
                    //}
                    if (TextBoxGroupID.Text == "")
                    {
                    }
                    else if (TextBoxGroupID.Text == "0")
                    {
                        TextBoxGroupID.Text   = "0";
                        TextBoxGroupName.Text = "Root";
                    }
                    else
                    {
                        foreach (DataRow row in DTGroupID.Rows)
                        {
                            if (row[TableCostCenter.ID].ToString() == TextBoxGroupID.Text)
                            {
                                //MessageBox.Show("موجود مسبقا");
                                //TextBoxID.Focus();
                                //m = true;

                                if (row[TableCostCenter.IsGroup].ToString() == "0")
                                {
                                    MessageBox.Show("لا يمكن الإضافة");
                                    TextBoxGroupID.Focus();
                                    TextBoxGroupID.Clear();
                                    Exsists = true;
                                }

                                else
                                {
                                    TextBoxGroupID.Text   = row[TableCostCenter.ID].ToString();
                                    TextBoxGroupName.Text = row[TableCostCenter.NameLng1].ToString();
                                    Exsists = true;
                                    break;
                                }
                            }
                        }

                        //if (TextBoxGroupID.Text == DTGroupID.Rows[0][TableCostCenter.ID].ToString())
                        //     {
                        //        TextBoxGroupID.Text = DTGroupID.Rows[0][TableCostCenter.ID].ToString();
                        //        TextBoxGroupName.Text = DTGroupID.Rows[0][TableCostCenter.NameLng1].ToString();

                        //     }
                        //else if (DTGroupID.Rows[0][TableCostCenter.IsGroup].ToString() == "0")
                        //{
                        //    MessageBox.Show("لا يمكن إضافة");
                        //    TextBoxGroupID.Focus();
                        //}
                        if (Exsists == false)
                        {
                            //m = true;
                            MessageBox.Show("غير موجود");
                            TextBoxGroupID.Clear();
                            DTGroupID.Clear();
                            TextBoxGroupID.Focus();
                            buttonGroupSearch_Click(sender, e);
                        }
                        //else
                        //{
                        //    MessageBox.Show("غير موجود");
                        //    TextBoxGroupID.Focus();

                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }