private bool ValidateFields(string db_host, string db_name, string db_username) { bool result = true; if (string.IsNullOrEmpty(db_host) || db_host.ToLower() == "host") { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_HOST_NOT_EMPTY, ToolTipIcon.Warning); return(false); } else if (db_host.ToLower() != Constant.LOCALHOST_VALUE) { if (!TKHelper.ValidateIPv4(db_host)) { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_INVALID_HOST, ToolTipIcon.Warning); return(false); } } if (string.IsNullOrEmpty(db_name) || db_name.ToLower() == "database name") { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_DATABASE_NAME_NOT_EMPTY, ToolTipIcon.Warning); return(false); } if (string.IsNullOrEmpty(db_username) || db_username.ToLower() == "username") { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_USERNAME_NOT_EMPTY, ToolTipIcon.Warning); return(false); } return(result); }
private bool ValidateFields(string db_host, string db_name, string db_username, string db_password) { bool result = true; TKHelper tk = new TKHelper(); if (string.IsNullOrEmpty(db_host) || db_host == "Host") { MessageBox.Show("Field 'Host' Belum Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } else if (db_host.ToLower() != "localhost") { if (!tk.ValidateIPv4(db_host)) { MessageBox.Show("Invalid Host.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } if (string.IsNullOrEmpty(db_name) || db_name == "Database Name") { MessageBox.Show("Field 'Name' Belum Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (string.IsNullOrEmpty(db_username) || db_username == "Username") { MessageBox.Show("Field 'Username' Belum Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (string.IsNullOrEmpty(db_password) || db_password == "Password") { MessageBox.Show("Field 'Password' Belum Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(result); }
private void save_Click(object sender, EventArgs e) { string ipv4 = textBox1.Text.ToString(); string ipv4_live_cam = textBox2.Text.ToString(); int width = Convert.ToInt32(txtWidth.Text); int height = Convert.ToInt32(txtHeight.Text); TKHelper tk = new TKHelper(); if (ipv4 != "" && ipv4 != "IP Address Server" && ipv4 != null) { if (ipv4_live_cam != "" && ipv4_live_cam != "IP Address Live Camera" && ipv4_live_cam != null) { if (tk.ValidateIPv4(ipv4)) { if (tk.ValidateIPv4(ipv4_live_cam)) { Properties.Settings.Default.IPAddressServer = ipv4; Properties.Settings.Default.IPAddressLiveCamera = ipv4_live_cam; Properties.Settings.Default.WebcamWidth = width; Properties.Settings.Default.WebcamHeight = height; Properties.Settings.Default.Save(); IPAddressServer = ipv4; IPAddressLiveCamera = ipv4_live_cam; MessageBox.Show("Setting Berhasil Diupdate.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Invalid IP Address Live Camera.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Invalid IP Address Server.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("IP Address Live Camera Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("IP Address Server Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void save_Click(object sender, EventArgs e) { string ipv4 = textBox1.Text.ToString(); if (ipv4 != "" && ipv4 != "IP Server" && ipv4 != null) { if (TKHelper.ValidateIPv4(ipv4)) { Properties.Settings.Default.IPAddressServer = ipv4; Properties.Settings.Default.Save(); IPAddressServer = ipv4; notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Success", Constant.SETTING_UPDATE_SUCCESS, ToolTipIcon.Info); } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_INVALID_IP_ADDRESS_SERVER, ToolTipIcon.Warning); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.WARNING_MESSAGE_IP_ADDRESS_SERVER_NOT_EMPTY, ToolTipIcon.Warning); } }