Пример #1
0
        public static Hashtable SimpleQuery(string TableName, string Where, string OrderBy,
                                            string Columns)
        {
            Hashtable HT = new Hashtable();

            try
            {
                using (DbConnection Conn = Settings.Factory.CreateConnection())
                {
                    Conn.ConnectionString = Settings.ConnectionString;
                    try
                    {
                        Conn.Open();
                    }
                    catch
                    {
                        MessageBox.Show(QSError.GiveErrorMessage(QSError.ErrorCodes.VeritabaninaUlasilamiyor));
                        Environment.Exit(0);
                    }

                    DataSet       DS   = new DataSet();
                    DataTable     DT   = new DataTable();
                    DbDataAdapter DAP  = Settings.Factory.CreateDataAdapter();
                    DbCommand     Comm = Settings.Factory.CreateCommand();
                    Comm.Connection = Conn;
                    string strCommand = "SELECT " + Columns + " FROM " + TableName + " " + Where + " " + OrderBy;
                    Comm.CommandText  = strCommand;
                    DAP.SelectCommand = Comm;
                    DAP.Fill(DS);
                    DAP.Fill(DT);
                    HT.Add("DataSet", DS);
                    HT.Add("DataTable", DT);
                    HT.Add("DataCount", DS.Tables[0].Rows.Count);
                    Conn.Close();
                    DAP.Dispose();
                    Comm.Dispose();
                }
            }
            catch (Exception Ex)
            {
                HT.Add("Error", Ex.Message);
            }
            return(HT);
        }
Пример #2
0
        public bool Login(string pUserName, string pPass, string terminalId)
        {
            Username = pUserName;
            Pass     = pPass;

            DataTable dtUserInf;
            Hashtable hshUserResult = DBProcess.SimpleQuery(
                "PERSONELLER",
                "WHERE KULLANICI_ADI='" + Username + "' AND SIFRE='" + Pass + "'",
                "",
                "PID, TID, AD, SOYAD, OTURUM_DURUM"
                );


            if (hshUserResult.ContainsKey("Error"))
            {
                if (FailedLogin != null)
                {
                    FailedLogin(new FailedLoginEventArgs(
                                    QSError.GiveErrorMessage(QSError.ErrorCodes.VeritabaninaUlasilamiyor)));
                }
                return(false);
            }

            dtUserInf = (DataTable)hshUserResult["DataTable"];
            if (dtUserInf.Rows.Count > 0)
            {
                PersonelId = int.Parse(dtUserInf.Rows[0]["PID"].ToString());
                Ad         = dtUserInf.Rows[0]["AD"].ToString();
                Soyad      = dtUserInf.Rows[0]["SOYAD"].ToString();
                TerminalId = (terminalId == "0" ? int.Parse(dtUserInf.Rows[0]["TID"].ToString()) : Convert.ToInt32(terminalId));  //aha buraya combodan doldur.

                Hashtable hshTerminalResult = DBProcess.SimpleQuery(
                    "TERMINALLER", "WHERE TID=" + TerminalId, "", "TID, TERMINAL_AD");

                if (hshTerminalResult.ContainsKey("DataTable"))
                {
                    DataTable dtTerminalInf = (DataTable)hshTerminalResult["DataTable"];
                    if (!(dtTerminalInf.Rows.Count > 0))
                    {
                        if (FailedLogin != null)
                        {
                            FailedLogin(new FailedLoginEventArgs(
                                            "Giriş yapılmaya çalışılan personele ait bir terminal kaydı bulunmamaktadır! Lütfen QCU üzerinden personele bir terminal ataması yapınız."));
                        }
                        return(false);
                    }
                    else
                    {
                        TerminalAdi = dtTerminalInf.Rows[0]["TERMINAL_AD"].ToString();
                    }
                }

                UpdateLoginState(true);
                if (SuccessLogin != null)
                {
                    SuccessLogin(new SuccesLoginEventArgs(this));
                }
                return(true);
            }
            if (FailedLogin != null)
            {
                FailedLogin(new FailedLoginEventArgs("Kullanıcı adı ve/veya şifreyi hatalı girdiniz!"));
            }
            return(false);
        }