private void Btn_LogIn_Click(object sender, EventArgs e) { if (!IsLoginInfoValid()) { FRM_MessageBox.Show("ID와 PW를 모두 입력해 주세요", "로그인 실패"); return; } LogIn(); }
private void LogIn() { IniFile iniFile = new IniFile(); iniFile.Load(IniData.SettingIniFile); IniSection dbSection = iniFile[DBConnect.IniSectionName]; string commandText = $@"Select * from {dbSection["UserTB"]} where {dbSection["UserTB_ID"]} = @ID and {dbSection["UserTB_PW"]} = @Password"; SqlCommand command = new SqlCommand(commandText); SqlParameter paramID = new SqlParameter("@ID", SqlDbType.VarChar, 40); paramID.Value = Txt_ID.Text; SqlParameter paramPW = new SqlParameter("@Password", SqlDbType.VarChar, 40); paramPW.Value = Txt_PW.Text; command.Parameters.Add(paramID); command.Parameters.Add(paramPW); DBConnect dbConnect = new DBConnect(); DataSet loginData; bool result = dbConnect.Search(command, out loginData); if (result && loginData != null) { this.DialogResult = DialogResult.OK; this.Close(); } else { if (result && loginData == null) { FRM_MessageBox.Show("입력하신 ID 또는 PW가 맞지 않습니다", "로그인 실패"); } else { FRM_MessageBox.Show("로그인 DB의 접속에 실패했습니다", "로그인 실패"); } } }
private void Txt_DefectAmount_TextChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(Txt_DefectAmount.Text)) { return; } int currentProd; int defectAmount = int.Parse(Txt_DefectAmount.Text); if (int.TryParse(Txt_TotalAmount.Text, out currentProd) && defectAmount <= currentProd) { Txt_NormalAmount.Text = (currentProd - defectAmount).ToString(); } else { // 괄호 내 문장은 Txt_DefectAmount_Click 함수 내에 물품 생산 여부를 확인하는 코드가 들어가면 지워질 예정 FRM_MessageBox.Show("(생산 중이 아니거나 )입력한 불량품의 수가 너무 많습니다", "잘못된 입력 확인"); Txt_DefectAmount.Text = ""; return; } }