예제 #1
0
 //private void AutoComCollection()
 //{
 //    string sPaymentDay = "All";
 //    string sPayMode = "Daily";
 //    string sDelegataID = "10001";
 //    for (int i = 10000; i < 15000; i++)
 //    {
 //        string sInsertCommand = "insert into Customer values('" + NewCustomer.GetNextCustomerID().ToString() + "', '" +
 //                                                            i.ToString() + "', '" +
 //                                                            i.ToString() + "', '" +
 //                                                            i.ToString() + "', '" +
 //                                                            i.ToString() + "', '" +
 //                                                            sPayMode + "', '" +
 //                                                            sPaymentDay + "', '" +
 //                                                            i.ToString() + "', '" +
 //                                                            i.ToString() + "', '" + // when creating a customer total amount = balance payment.
 //                                                            "0', '" + // Due amount is 0 when creating a customer.
 //                                                            sDelegataID + "', '" +
 //                                                             "0', '" +
 //                                                              "11/6/2012 12:00:00 AM', '" +
 //                                                              "false', '" +
 //                                                              "false', '" +
 //                                                              "0'" +
 //                                                             ")";
 //        DBWrapper.ExecuteNonQueryEx(sInsertCommand);
 //    }
 //}
 private void btn_OK_Click(object sender, EventArgs e)
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("Login::btn_OK_Click()"))
     {
         try
         {
             CheckPassword();
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 
 /// </summary>
 static DBWrapper()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::DBWrapper()"))
     {
         try
         {
             ConnectDB();
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
     }
 }
예제 #3
0
 public Login()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("Login::Login()"))
     {
         try
         {
             Tracer.TraceFlag = true;
             InitializeComponent();
             text_password.Focus();
             combo_Domain.SelectedIndex = 1;
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
     }
 }
예제 #4
0
        public static int GetTopBatchId()
        {
            int nBatchID = 0;
            using (AutomaticLogger automaticLogger = new AutomaticLogger("Common::GetTopBatchId`()"))
            {
                try
                {

                    string sQuery = "Setcct Max(BatchID) from Batch";

                }
                catch (System.Exception exception_ex)
                {
                    automaticLogger.Error(exception_ex);
                }
            }
            return nBatchID;
        }
예제 #5
0
 /// <summary>
 /// GetConnectionString
 /// </summary>
 /// <returns></returns>
 private static string GetConnectionString()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::GetConnectionString()"))
     {
         string csConectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=";
         try
         {
             string csPath = System.Environment.CurrentDirectory + "\\dataBase\\eduMaster.mdf";
             csConectionString += csPath;
             csConectionString += ";Integrated Security=True;Connect Timeout=30;User Instance=True";
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
         return csConectionString;
     }
 }
예제 #6
0
 /// <summary>
 /// ConnectDB
 /// </summary>
 private static void ConnectDB()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::ConnectDB()"))
     {
         try
         {
             _SqlConnection = new SqlConnection(GetConnectionString());
             if (_SqlConnection.State != ConnectionState.Open)
             {
                 _SqlConnection.Open();
             }
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
     }
 }
예제 #7
0
 /// <summary>
 /// SetCommand
 /// </summary>
 /// <param name="csQuery"></param>
 /// <returns></returns>
 public static SqlCommand SetCommand(string csQuery)
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::SetCommand()"))
     {
         SqlCommand sqlCommand = null;
         try
         {
             sqlCommand = new SqlCommand();
             sqlCommand.CommandText = csQuery;
             sqlCommand.Connection = _SqlConnection;
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
         return sqlCommand;
     }
 }
예제 #8
0
 /// <summary>
 /// ExecuteQuery
 /// </summary>
 /// <param name="sQuery_i"></param>
 /// <returns></returns>
 public static SqlDataReader ExecuteQuery(string sQuery_i)
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::ExecuteQuery()"))
     {
         SqlDataReader sqlDataReader = null;
         try
         {
             if (null == sQuery_i)
             {
                 return null;
             }
             SqlCommand sqlCommand = SetCommand(sQuery_i);
             sqlDataReader = sqlCommand.ExecuteReader();
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
         return sqlDataReader;
     }
 }
예제 #9
0
 public static bool ExecuteNonQueryEx(string sQuery_i)
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::ExecuteNonQueryEx()"))
     {
         bool bResult = false;
         try
         {
             if (null == sQuery_i)
             {
                 return false;
             }
             else
             {
                 SqlCommand sqlCommand = SetCommand(sQuery_i);
                 int nEffectedRows = 0;
                 nEffectedRows = sqlCommand.ExecuteNonQuery();
                 if (nEffectedRows > 0)
                 {
                     bResult = true;
                 }
             }
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
         return bResult;
     }
 }
예제 #10
0
 /// <summary>
 /// DisConnectDB
 /// </summary>
 public static void DisConnectDB()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("DBWrapper::DisConnectDB()"))
     {
         try
         {
             if (_SqlConnection.State != ConnectionState.Closed)
             {
                 _SqlConnection.Close();
             }
         }
         catch (System.Exception exception_ex)
         {
             automaticLogger.Error(exception_ex);
         }
     }
 }
예제 #11
0
 private void CheckPassword()
 {
     using (AutomaticLogger automaticLogger = new AutomaticLogger("Login::CheckPassword()"))
     {
         if (GlxSecure.ValidatePassword(combo_user.Text, text_password.Text))
         {
             this.Hide();
             eduMaster eduMasterMainForm = new eduMaster();
             eduMasterMainForm.ShowDialog();
             Application.Exit();
         }
         else
         {
             if (text_password.Text != "")
             {
                 text_password.ForeColor = Color.Red;
             }
         }
     }
 }
예제 #12
0
        /// <summary>
        /// LoadUsername
        /// </summary>
        private void LoadUsername()
        {
            using (AutomaticLogger automaticLogger = new AutomaticLogger("Login::LoadUsername()"))
            {
                string csQuery = "Select UserName from Users where Domain ='" + combo_Domain.Text + "'";
                try
                {
                    SqlDataReader sqlDataReader = DBWrapper.ExecuteQuery(csQuery);
                    if (null!=sqlDataReader)
                    {
                        while (sqlDataReader.Read())
                        {
                            combo_user.Items.Add(sqlDataReader.GetString(0));
                        };
                        sqlDataReader.Close();
                        if (0 < combo_user.Items.Count)
                        {
                            combo_user.SelectedIndex = 0;
                        }
                    }
                    else
                    {

                    }
                }
                catch (Exception exception_ex)
                {
                    automaticLogger.Error(exception_ex);
                }
            }
        }