private void btn_add_Click(object sender, EventArgs e) { bool isError = false; int itemTypeIdId = Convert.ToInt16(txt_itemTypeID.Text); string itemType = txt_itemType.Text; try { //check for do action if (COMM_METHODS.checkActPermission(this.Name, USERNAME)) { //validate item Type name if (VALIDATION.isEmptyTextBox(itemType)) { COM_MESSAGE.validationMessage("Item Type Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(itemType)) { COM_MESSAGE.validationMessage("Item Type should contains only Letters and Numbers !!!"); isError = true; } } if (!isError) { //insert data to tbl_itemtype if (MANAGEDB.insertData_itemType(itemTypeIdId, itemType)) { IS_SUCCESS_MESSAGE = true; COM_MESSAGE.successfullMessage("Successfully created the Item Type !!!"); clearAllText(this); txt_itemTypeID.Text = MANAGEDB.getMaxItemTypeID().ToString(); txt_itemType.Focus(); } } } else { COM_MESSAGE.permissionMessage("Sorry You dont have permission to do action !!!"); } } catch (Exception ex) { COM_MESSAGE.exceptionMessage(ex.Message); } }
private bool checkInsertedDealerData(List <Tuple <string, string> > dealerData) { bool isError = false; try { for (int i = 0; i < dealerData.Count; i++) { switch (dealerData[i].Item1) { case "dealerName": if (VALIDATION.isEmptyTextBox(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Dealer Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Dealer Name should contains only Numbers and letters !!!"); isError = true; } } break; case "companyName": if (VALIDATION.isEmptyTextBox(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Company Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Company Name should contains only Numbers and letters !!!"); isError = true; } } break; case "phoneNo": if (!VALIDATION.isEmptyTextBox(dealerData[i].Item2)) { if (!VALIDATION.isNumberOnly(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Phone Number should contains only numbers !!!"); isError = true; } } break; case "mobile": if (!VALIDATION.isEmptyTextBox(dealerData[i].Item2)) { if (!VALIDATION.isNumberOnly(dealerData[i].Item2)) { COM_MESSAGE.validationMessage("Mobile Phone Number should contains only numbers !!!"); isError = true; } } break; default: break; } } } catch (Exception ex) { throw ex; } return(isError); }
private void btnLogin_Click(object sender, EventArgs e) { lbl_userNameEmpty.Visible = false; lbl_passwdEmpty.Visible = false; lbl_invalidUser.Visible = false; pnl_userName.BackgroundImage = null; pnl_pass.BackgroundImage = null; bool isError = false; try { //validate userName if (VALIDATION.isEmptyTextBox(txtUserName.Text)) { lbl_userNameEmpty.Visible = true; lbl_userNameEmpty.Text = "User Name is empty"; lbl_userNameEmpty.ForeColor = Color.Red; pnl_userName.BackgroundImage = (Image)CommonControls.Properties.Resources.ng; txtUserName.Focus(); isError = true; } else { if (VALIDATION.isSpecialChars(txtUserName.Text)) { lbl_userNameEmpty.Visible = true; lbl_userNameEmpty.Text = "User Name Cannot contains special characters"; lbl_userNameEmpty.ForeColor = Color.Red; pnl_userName.BackgroundImage = (Image)CommonControls.Properties.Resources.ng; txtUserName.Focus(); isError = true; } } if (VALIDATION.isEmptyTextBox(txtPassword.Text)) { lbl_passwdEmpty.Visible = true; lbl_passwdEmpty.Text = "Password is empty"; lbl_passwdEmpty.ForeColor = Color.Red; pnl_pass.BackgroundImage = (Image)CommonControls.Properties.Resources.ng; txtPassword.Focus(); isError = true; } else { if (VALIDATION.isSpecialChars(txtPassword.Text)) { lbl_passwdEmpty.Visible = true; lbl_passwdEmpty.Text = "Password cannot contains special characters"; lbl_passwdEmpty.ForeColor = Color.Red; pnl_pass.BackgroundImage = (Image)CommonControls.Properties.Resources.ng; txtPassword.Focus(); isError = true; } } if (!isError) { if (isValidUser()) { USERNAME = txtUserName.Text; this.Hide(); Frm_Main MainForm = new Frm_Main(); MainForm.Show(); } else { lbl_invalidUser.Visible = true; lbl_invalidUser.Text = "Invalid userName or Password"; lbl_invalidUser.ForeColor = Color.Red; txtPassword.Text = String.Empty; txtUserName.Text = String.Empty; txtUserName.Focus(); } } } catch (Exception ex) { COMM_MESSAGE.exceptionMessage(ex.Message); } }
private bool checkInsertedItemData(List <Tuple <string, string> > userData) { bool isError = false; try { for (int i = 0; i < userData.Count; i++) { switch (userData[i].Item1) { case "itemCode": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("Item Code Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("Item Code should contains only Numbers !!!"); isError = true; } } break; case "itemName": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("Item Name Cannot be Empty !!!"); isError = true; } else { if (VALIDATION.isSpecialChars(userData[i].Item2)) { COM_MESSAGE.validationMessage("Item Name should not contains special characters !!!"); isError = true; } } break; case "altName": if (!VALIDATION.isEmptyTextBox(userData[i].Item2)) { if (VALIDATION.isSpecialChars(userData[i].Item2)) { COM_MESSAGE.validationMessage("Alternative Name should not contains special characters !!!"); isError = true; } } break; case "itemType": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("Item Type Cannot be Empty !!!"); isError = true; } break; default: isError = true; break; } } } catch (Exception ex) { throw ex; } return(isError); }
private bool checkInsertedStockEntry(List <Tuple <string, string> > stockEntry) { bool isError = false; try { for (int i = 0; i < stockEntry.Count; i++) { switch (stockEntry[i].Item1) { case "quantity": if (VALIDATION.isEmptyTextBox(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Quantity Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isDoubleValue(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Quantity is not Correct in format !!!"); isError = true; } } break; case "buyingUnitPrice": if (VALIDATION.isEmptyTextBox(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Buying Unit Price Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isDoubleValue(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Buying Unit Price is not in Correct format !!!"); isError = true; } } break; case "sellingUnitPrice": if (VALIDATION.isEmptyTextBox(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Selling Unit Price Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isDoubleValue(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Selling Unit Price is not in Correct format !!!"); isError = true; } } break; case "priceAfterDiscount": if (!VALIDATION.isEmptyTextBox(stockEntry[i].Item2)) { if (!VALIDATION.isDoubleValue(stockEntry[i].Item2)) { COM_MESSAGE.validationMessage("Price After Discount is not in Correct format !!!"); isError = true; } } break; default: break; } } } catch (Exception ex) { throw ex; } return(isError); }
private bool checkInsertedUserData(List <Tuple <string, string> > userData) { bool isError = false; try { for (int i = 0; i < userData.Count; i++) { switch (userData[i].Item1) { //validate User Name case "userName": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("User Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("User Name should contains only Letters and Numbers !!!"); isError = true; } } break; //validate First Name case "firstName": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("First Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("First Name should contains only Letters !!!"); isError = true; } } break; //validate Last Name case "lastName": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("Last Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("Last Name should contains only Letters !!!"); isError = true; } } break; //validate NIC case "idNumber": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("NIC Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("NIC should contains only Letters and Numbers !!!"); isError = true; } } break; //validate email - it can be empty case "email": if (!VALIDATION.isEmptyTextBox(userData[i].Item2)) { if (!VALIDATION.isEmail(userData[i].Item2)) { COM_MESSAGE.validationMessage("email is not in correct format !!!"); isError = true; } } break; //validate user Role case "userRole": if (VALIDATION.isEmptyTextBox(userData[i].Item2)) { COM_MESSAGE.validationMessage("User Role Cannot be Empty !!!"); isError = true; } break; //validate Phone number case "phoneNo": if (!VALIDATION.isEmptyTextBox(userData[i].Item2)) { if (!VALIDATION.isNumberOnly(userData[i].Item2)) { COM_MESSAGE.validationMessage("Phone Number should contains only Numbers !!!"); isError = true; } } break; default: isError = true; break; } } } catch (Exception ex) { throw ex; } return(isError); }
private void btn_create_Click(object sender, EventArgs e) { bool isError = false; string userName = txt_userName.Text; string firstName = txt_firstName.Text; string lastName = txt_lastName.Text; string idNumber = txt_nic.Text; string email = txt_email.Text; string userRole = dropDown_userRole.SelectedItem.ToString(); string phoneNo = txt_phoneNumber.Text; //validate User Name if (VALIDATION.isEmptyTextBox(userName)) { COM_MESSAGE.validationMessage("User Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(userName)) { COM_MESSAGE.validationMessage("User Name should contains only Letters and Numbers !!!"); isError = true; } } //validate First Name if (VALIDATION.isEmptyTextBox(firstName)) { COM_MESSAGE.validationMessage("First Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterOnly(firstName)) { COM_MESSAGE.validationMessage("First Name should contains only Letters !!!"); isError = true; } } //validate Last Name if (VALIDATION.isEmptyTextBox(lastName)) { COM_MESSAGE.validationMessage("Last Name Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterOnly(lastName)) { COM_MESSAGE.validationMessage("Last Name should contains only Letters !!!"); isError = true; } } //validate NIC if (VALIDATION.isEmptyTextBox(idNumber)) { COM_MESSAGE.validationMessage("NIC Cannot be Empty !!!"); isError = true; } else { if (!VALIDATION.isLetterAndNumberOnly(idNumber)) { COM_MESSAGE.validationMessage("NIC should contains only Letters and Numbers !!!"); isError = true; } } //validate email - it can be empty if (!VALIDATION.isEmptyTextBox(email)) { if (!VALIDATION.isEmail(email)) { COM_MESSAGE.validationMessage("email is not in correct format !!!"); isError = true; } } //validate user Role if (VALIDATION.isEmptyTextBox(userRole)) { COM_MESSAGE.validationMessage("User Role Cannot be Empty !!!"); isError = true; } //validate Phone number if (!VALIDATION.isEmptyTextBox(phoneNo)) { if (!VALIDATION.isNumberOnly(phoneNo)) { COM_MESSAGE.validationMessage("Phone Number should contains only Numbers !!!"); isError = true; } } if (!isError) { //insert data to db CREATEUSER._userId = Convert.ToInt16(txt_userID.Text); CREATEUSER._userName = userName; CREATEUSER._firstName = firstName; CREATEUSER._lastName = lastName; CREATEUSER._dob = Convert.ToDateTime(txt_dob.Text); CREATEUSER._idNumber = idNumber; CREATEUSER._address = txt_address.Text; CREATEUSER._email = email; CREATEUSER._userRole = userRole; CREATEUSER._roleId = Convert.ToInt16(dropDown_userRole.SelectedValue); } }