private void changePasswordButton_Click(object sender, EventArgs e) { bool error = false; SupplierDA sda = new SupplierDA(); Supplier sup = sda.getOneSupplierByID(supplierID, conn); if (string.IsNullOrWhiteSpace(currentPasswordTextBox.Text) || !Security.verifyHash(currentPasswordTextBox.Text, "SHA512", sup.getPassword())) { currentPasswordErrorLabel.Visible = true; error = true; } else { currentPasswordErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(newPasswordTextBox.Text) || !FormatChecker.checkPasswdFormat(newPasswordTextBox.Text)) { newPasswordErrorLabel.Visible = true; error = true; } else { newPasswordErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(confirmPasswordTextBox.Text) || !newPasswordTextBox.Text.Equals(confirmPasswordTextBox.Text)) { confirmPasswordErrorLabel.Visible = true; error = true; } else { confirmPasswordErrorLabel.Visible = false; } if (!error) { sup.setPassword(Security.getHash(newPasswordTextBox.Text, "SHA512", null)); int i = sda.update(sup, sup.getSupplierID(), conn); if (i > 0) { MessageBox.Show(rs.GetString("passwordChangedMsg")); sup = null; } else { MessageBox.Show(rs.GetString("failToChangePasswdMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } currentPasswordTextBox.Clear(); newPasswordTextBox.Clear(); confirmPasswordTextBox.Clear(); }
public decimal Update(SupplierInfo supplier) { decimal ck = -1; try { SupplierDA _da = new SupplierDA(); ck = _da.Update(supplier); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); } return(ck); }
public decimal Delete(decimal id) { decimal ck = -1; try { SupplierDA _da = new SupplierDA(); ck = _da.Delete(id); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); } return(ck); }
public SupplierInfo GetbyId(decimal id) { List <SupplierInfo> list = new List <SupplierInfo>(); try { SupplierDA _da = new SupplierDA(); list = CBO <SupplierInfo> .FillCollectionFromDataSet(_da.GetById(id)); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); } return(list[0]); }
public List <SupplierInfo> GetAll() { List <SupplierInfo> list = new List <SupplierInfo>(); try { SupplierDA _da = new SupplierDA(); list = CBO <SupplierInfo> .FillCollectionFromDataSet(_da.GetAll()); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); } return(list); }
public List <SupplierInfo> Search(string keysearch, ref decimal p_total_record, string p_from = "1", string p_to = "10") { List <SupplierInfo> list = new List <SupplierInfo>(); SupplierDA _da = new SupplierDA(); try { list = CBO <SupplierInfo> .FillCollectionFromDataSet(_da.Search(keysearch, p_from, p_to, ref p_total_record)); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); list = new List <SupplierInfo>(); } return(list); }
private void showProfile() { SupplierDA sda = new SupplierDA(); Supplier s = sda.getOneSupplierByID(supplierID, conn); showSupplierIdLabel.Text = s.getSupplierID(); showNameLabel.Text = s.getSupplierName(); showContectNoLabel.Text = s.getContectNo(); showEmailLabel.Text = s.getEmail(); if (s.getProductCategory().Equals("Bottle")) { showCategoryLabel.Text = rs.GetString("bottleText"); } else if (s.getProductCategory().Equals("Package")) { showCategoryLabel.Text = rs.GetString("packageText"); } else if (s.getProductCategory().Equals("Perfume")) { showCategoryLabel.Text = rs.GetString("perfumeText"); } showAddressLabel.Text = s.getAddress(); }
public ActionResult AjaxForm() { var model = new StorageWarehousingItem(); if (DoAction == ActionType.Edit) { model = _api.GetStorageWarehousingItem(ArrId.FirstOrDefault()); } ViewBag.UserID = UserItem.UserId; ViewBag.User = UserItem.UserName; var agent = _dnAgencyApi.GetItemById(UserItem.AgencyID); ViewBag.Wallet = agent.WalletValue; ViewBag.Deposit = UserItem.AgencyDeposit ?? 0; ViewBag.marketId = UserItem.MarketID; ViewBag.areaId = UserItem.AreaID; ViewBag.listtime = TypeTime.Hours(DateTime.Today.AddDays(1).TotalSeconds(), DateTime.Now.AddHours(12).TotalSeconds()); ViewBag.Action = DoAction; SupplierDA _supplierDa = new SupplierDA(); return(View(model)); }
private void loginButton_Click(object sender, EventArgs e) { try { SupplierDA sda = new SupplierDA(); Supplier sup = sda.getOneSupplierByID(idTextbox.Text, conn); SupplierLoginLogDA slda = new SupplierLoginLogDA(); if (!string.IsNullOrWhiteSpace(idTextbox.Text) && !string.IsNullOrEmpty(passwordTextbox.Text)) { if (!string.IsNullOrWhiteSpace(sup.getSupplierID()) && !string.IsNullOrWhiteSpace(sup.getPassword())) { List <LoginLog> logs = slda.searchLogs(DateTime.Now.AddHours(-0.5), DateTime.Now, sup.getSupplierID(), "", conn); bool isLocked = false; DateTime?unlockedTime = null; for (int i = 0; i < logs.Count; i++) { if (logs.ElementAt(i).getLocked()) { isLocked = true; } if (!string.IsNullOrEmpty(logs.ElementAt(i).getUnlockedByEmpID())) { isLocked = false; unlockedTime = logs.ElementAt(i).getTime(); } } if (isLocked) { LoginLog ll = new LoginLog(); ll.setAccountID(sup.getSupplierID()); ll.setSuccess(false); ll.setPasswordIncorrect(false); ll.setLocked(false); ll.setAcStatusTempLock(true); ll.setTime(DateTime.Now); slda.insert(ll, conn); MessageBox.Show(rs.GetString("accountLockedMsg"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (unlockedTime.HasValue) { logs = null; logs = slda.searchLogs(unlockedTime.Value.AddMinutes(1), DateTime.Now, sup.getSupplierID(), "", conn); } if (sup.getSupplierID().Equals(idTextbox.Text) && Security.verifyHash(passwordTextbox.Text, "SHA512", sup.getPassword())) { LoginLog ll = new LoginLog(); ll.setAccountID(sup.getSupplierID()); ll.setSuccess(true); ll.setPasswordIncorrect(false); ll.setLocked(false); ll.setAcStatusTempLock(false); ll.setTime(DateTime.Now); slda.insert(ll, conn); for (int i = 0; i < formList.Length; i++) { if (sup.getProductCategory().Equals(formList[i][0])) { Visible = false; mainForm = (Form)Activator.CreateInstance(Type.GetType(GetType().Namespace + "." + formList[i][1] + ".MainForm"), sup.getSupplierID()); mainForm.FormClosed += new FormClosedEventHandler(mainForm_Closed); showStockAlert(sup.getSupplierID(), sup.getProductCategory()); showRecycleBinAlert(sup.getSupplierID(), sup.getProductCategory()); mainForm.ShowDialog(); break; } } } else { int attempts = 1; for (int i = 0; i <= logs.Count; i++) { if (i < logs.Count) { if (logs.ElementAt(i).getPasswordIncorrect()) { if (attempts == 4) { LoginLog ll = new LoginLog(); ll.setAccountID(sup.getSupplierID()); ll.setSuccess(false); ll.setPasswordIncorrect(true); ll.setLocked(true); ll.setAcStatusTempLock(false); ll.setTime(DateTime.Now); slda.insert(ll, conn); MessageBox.Show(rs.GetString("accountLock30MinMsg"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } attempts++; } else if (logs.ElementAt(i).getSuccess()) { attempts = 1; } } else if (i == logs.Count) { LoginLog ll = new LoginLog(); ll.setAccountID(sup.getSupplierID()); ll.setSuccess(false); ll.setPasswordIncorrect(true); ll.setLocked(false); ll.setAcStatusTempLock(false); ll.setTime(DateTime.Now); slda.insert(ll, conn); MessageBox.Show(rs.GetString("idPasswdIncorrectMsg"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } else { MessageBox.Show(rs.GetString("idPasswdIncorrectMsg"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(rs.GetString("inputIdPasswordMsg"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); } idTextbox.Text = ""; passwordTextbox.Text = ""; } catch (MySqlException ex) { Database.showErrorMessage(ex.Number); } catch (Exception) { MessageBox.Show("System error.\nPlease contact administrator.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.ExitThread(); } }
//--Constructor public SupplierBL() { _da = new SupplierDA(); }