Пример #1
0
        public bool validateControls()
        {
            int            id;
            string         ErrorString      = "";
            SupplierMaster supplierEntities = new SupplierMaster();

            try
            {
                supplierEntities.supplierId     = int.TryParse(txtSupplierId.Text, out id) == true ? id : 0;
                supplierEntities.supplierName   = txtSupplierName.Text;
                supplierEntities.supplierStatus = cmbStatus.SelectedIndex;

                supplier    = new SupplierMasterBL();
                ErrorString = supplier.ValidationOfControls(supplierEntities);

                if (!string.IsNullOrEmpty(ErrorString))
                {
                    if (ErrorString == "txtSupplierId")
                    {
                        MessageBox.Show("Supplier Id Cannot be Empty!!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtSupplierId.Focus();
                        return(false);
                    }

                    else if (ErrorString == "txtSupplierName")
                    {
                        MessageBox.Show("Supplier Name Cannot be Empty!!! OR It Cannot Exceed 10 Characters...", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtSupplierName.Focus();
                        return(false);
                    }

                    else if (ErrorString == "cmbStatus")
                    {
                        MessageBox.Show("Supplier Status Cannot be Empty!!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        cmbStatus.Select();
                        return(false);
                    }
                }
            }

            catch (Exception ex)
            {
                string errorMessage = ErrorHandling.Class1.CreateErrorMessage(ex);
                ErrorHandling.Class1.LogFileWrite(errorMessage);
                return(false);
            }

            return(true);
        }
Пример #2
0
        private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
        {
            //spSearchSupplierById
            supplier = new SupplierMasterBL();
            dt       = new DataTable();
            int Id = 0;

            if (e.KeyChar == (char)13)
            {
                if (supplier.ValidationOfControls(txtSearch.Text))
                {
                    dataGridView1.Rows.Clear();
                    dt = supplier.GetSupplierDetails(Convert.ToInt32(txtSearch.Text));

                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            dataGridView1.Rows.Add();
                            dataGridView1["SupplierId", i].Value     = dt.Rows[i]["SupplierId"];
                            dataGridView1["SupplierName", i].Value   = dt.Rows[i]["SupplierName"];
                            dataGridView1["SupplierStatus", i].Value = Convert.ToInt32(dt.Rows[i]["SupplierStatus"]) == 1 ? "Active" : "In Active";
                        }
                    }

                    else
                    {
                        MessageBox.Show("There is No Supplier Record with this Id.. ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                else
                {
                    MessageBox.Show("Please Enter the Number", "Earning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtSearch.Focus();
                }
            }
        }