예제 #1
0
        public CResult GetUser(CUserInfo inCat)
        {
            CResult oResult = null;
            try
            {
                //this.OpenConnection();
                //string sSql = string.Format(SqlQueries.GetQuery(Query.ItemGetById), gItemId);
                //IDataReader oReader = this.ExecuteReader(sSql);
                //if (oReader != null)
                //{
                //    if (oReader.Read())
                //        oItem = ReaderToCategory1(oReader);
                //}
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #2
0
        public CResult AddUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = String.Format(SqlQueries.GetQuery(Query.AddUser), inUser.UserName, inUser.Password, inUser.Type, inUser.Status, inUser.Gender);

                this.ExecuteNonQuery(sSql);

                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemInsert()", ex);
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #3
0
        public CResult DeleteUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory1));
                this.ExecuteNonQuery(sSql);

                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                throw new Exception("Exception occure at ItemDelete()", ex);
            }
            finally
            {
                this.CloseConnection();
            }

            return oResult;
        }
예제 #4
0
파일: LoginAction.cs 프로젝트: Jusharra/RMS
        public DialogResult OnEnterPress()
        {
            string password = passwordFiled.Text;

            CUserManager tempUserManager = new CUserManager();
            CUserInfo tempUserInfo = new CUserInfo();

            CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>();

            tempUserInfo = (CUserInfo)tempUserManager.GetUserInfoByUsername(CCurrentUser.User_name).Data;

            CLogin oLogin = new CLogin();
            CUserInfo oUserInfo = new CUserInfo();

            CPcInfoManager tempPcInfoManager = new CPcInfoManager();
            IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName());

            CPcInfo tempPcInfo = (CPcInfo)tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString()).Data;

            oUserInfo.UserName = CCurrentUser.User_name;
            RMSGlobal.LoginUserName = CCurrentUser.User_name;
            RMSGlobal.m_iLoginUserID = tempUserInfo.UserID;
            oUserInfo.Password = password;

            oUserInfo.PCID = tempPcInfo.PcID;
            RMSGlobal.m_connectionString = oConstant.DBConnection;
            oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL);

            CResult oResult = oLogin.ProcessLogin(oUserInfo);

            if (oResult.IsSuccess && oResult.Data != null)
            {
                CUserLogin oUserLogin = (CUserLogin)oResult.Data;

                oConstant.UserInfo = oUserLogin.UserInfo;
                lblErrorMessage.Hide();
            }
            else
            {
                string tempStr = oResult.Message;
                if (!tempStr.Equals(String.Empty))
                {
                    lblErrorMessage.Text = tempStr;
                }

                lblErrorMessage.Show();
                return DialogResult.None;
            }

            CCurrentUser.User_id = tempUserInfo.UserID;
            CCurrentUser.Type = tempUserInfo.Type;
            passwordFiled.Clear();
            return  DialogResult.OK;
        }
예제 #5
0
        public CResult DeleteUser(CUserInfo inUser)
        {
            try
            {
                m_oResult = RMS.DataAccess.Database.Instance.UserInfo.DeleteUser(inUser);

            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception occuer at DeleteItem() : " + ex.Message);
                m_oResult.IsException = true;
                m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE;
                m_oResult.SetParams(ex.Message);
                m_oResult.Message = ex.Message;
                Logger.Write("Exception : " + ex + " in DeleteItem()", LogLevel.Error, "CItemManager");
            }
            return m_oResult;
        }
예제 #6
0
        private CUserInfo ReaderToUserInfo(IDataReader oReader)
        {
            CUserInfo oUser = new CUserInfo();

            if (oReader["user_id"] != null)
                oUser.UserID = int.Parse(oReader["user_id"].ToString());

            if (oReader["user_name"] != null)
                oUser.UserName = oReader["user_name"].ToString();

            if (oReader["password"] != null)
                oUser.Password = oReader["password"].ToString();

            if (oReader["type"] != null)
                oUser.Type = int.Parse(oReader["type"].ToString());

            if (oReader["status"] != null)
                oUser.Status = int.Parse(oReader["status"].ToString());

            if (oReader["gender"] != null)
                oUser.Gender = oReader["gender"].ToString();

            return oUser;
        }
예제 #7
0
        private CUserAccess ReaderToUserAccess(IDataReader oReader, CUserAccess oUserAccess)
        {
            CUserInfo oItem = new CUserInfo();

            String sTempStr = String.Empty;

            if (oReader["name"] != null)
            {
                sTempStr = oReader["name"].ToString();

                if (sTempStr.Equals("OpenDrawer"))
                {
                    oUserAccess.OpenDrawer = 1;
                }
                else if (sTempStr.Equals("ReviewTransaction"))
                {

                    oUserAccess.ReviewTransaction = 1;
                }
                else if (sTempStr.Equals("VoidTable"))
                {
                    oUserAccess.VoidTable = 1;
                }
                else if (sTempStr.Equals("ViewReport"))
                {

                    oUserAccess.ViewReport = 1;

                }
                else if (sTempStr.Equals("TransferTable"))
                {

                    oUserAccess.TransferTable = 1;

                }
                else if (sTempStr.Equals("TillReporting"))
                {

                    oUserAccess.TillReporting = 1;
                }
                else if (sTempStr.Equals("MergeTable"))
                {

                    oUserAccess.MergeTable = 1;
                }
                else if (sTempStr.Equals("ExitRMS"))
                {

                    oUserAccess.ExitRms = 1;
                }
                else if (sTempStr.Equals("UnlockTable"))
                {

                    oUserAccess.UnlockTable = 1;
                }

                else if (sTempStr.Equals("Booking"))
                {

                    oUserAccess.Booking = 1;
                }
                else if (sTempStr.Equals("Users"))
                {

                    oUserAccess.Users = 1;
                }
                else if (sTempStr.Equals("Deposit"))
                {

                    oUserAccess.Deposit = 1;
                }
                else if (sTempStr.Equals("Customers"))
                {

                    oUserAccess.Customers = 1;
                }
                else if (sTempStr.Equals("UpdateItems"))
                {

                    oUserAccess.UpdateItems = 1;
                }
                else if (sTempStr.Equals("RemoveItems"))
                {

                    oUserAccess.RemoveItems = 1;
                }
                else if (sTempStr.Equals("LogRegister"))
                {

                    oUserAccess.LogRegister = 1;
                }
                else
                {
                }
            }
            return oUserAccess;
        }
예제 #8
0
        private CUserInfo ReaderToUserInfo(IDataReader oReader)
        {
            CUserInfo oItem = new CUserInfo();

            if (oReader["user_id"] != null)
                oItem.UserID = Int32.Parse(oReader["user_id"].ToString());

            if (oReader["user_name"] != null)
                oItem.UserName = oReader["user_name"].ToString();

            if (oReader["password"] != null)
                oItem.Password = oReader["password"].ToString();

            if (oReader["type"] != null)
                oItem.Type = Int32.Parse(oReader["type"].ToString());

            if (oReader["status"] != null)
                oItem.Status = Int32.Parse(oReader["status"].ToString());

            if (oReader["gender"] != null)
                oItem.Gender = oReader["gender"].ToString();

            return oItem;
        }
예제 #9
0
        public CResult LoginUser(CUserInfo inCat)
        {
            CResult oResult = new CResult();

            CUserInfo oUser = new CUserInfo();
            try
            {
                this.OpenConnection();

                string sSql = string.Format(SqlQueries.GetQuery(Query.LoginUser), inCat.UserName);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {

                        oUser = ReaderToUserInfo(oReader);

                        if ((!oUser.Password.Equals(String.Empty)) && oUser.Password.Equals(inCat.Password) && oUser.Status != 0)
                        {
                            //oReader.Close();
                            //sSql = string.Format(SqlQueries.GetQuery(Query.CheckCurrentUser), oUser.UserName);
                            // oReader = this.ExecuteReader(sSql);

                             oResult.Data = oUser;

                             oResult.IsSuccess = true;

                             //if (oReader != null)
                             //{

                             //    if (oReader.Read())
                             //    {

                             //        if (oReader["user_id"] != null)
                             //        {
                             //            int iTempInt5 = Int32.Parse(oReader["user_id"].ToString());

                             //            oResult.Message = "User already logged in.";

                             //        }

                             //    }

                             //    else
                             //    {
                             //        oReader.Close();

                             //        sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCurrentUser), oUser.UserID);

                             //        this.ExecuteNonQuery(sSql);

                             //        sSql = string.Format(SqlQueries.GetQuery(Query.AddCurrentUser), oUser.UserID, inCat.PCID);

                             //        this.ExecuteNonQuery(sSql);

                             //        oResult.Data = oUser;

                             //        oResult.IsSuccess = true;

                             //    }
                             //}// if null

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in LoginUser() in CUserInfoDAO ", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #10
0
        private void vatComplementoryButton_Click(object sender, EventArgs e)
        {
            CResult aCResult = new CResult();
              CUserInfoDAO aUserInfoDao = new CUserInfoDAO();
              CUserInfo aUserInfo = new CUserInfo();
              aUserInfo.UserID = RMSGlobal.m_iLoginUserID;
              aCResult = aUserInfoDao.GetUser(aUserInfo);
              aUserInfo = (CUserInfo)aCResult.Data;

              if (aUserInfo.Type != 0)
              {
              MessageBox.Show("You are not correct person to give Order Vat Complementory Opportunity");
              return;
              }

              COrderInfoDAO aOrderInfoDao = new COrderInfoDAO();
              string result = aOrderInfoDao.UpdateOrderVatComplementory(orderID, true);
              LoadOrderDetails();
              MessageBox.Show(result);
        }
예제 #11
0
        private void FinishButton_Click(object sender, EventArgs e)
        {
            try
            {
                CResult tempCheckForValidation = this.ValidateInput();
                if (tempCheckForValidation.IsSuccess)
                {
                    CUserInfo tempUser = new CUserInfo();

                    tempUser.UserName = NameTextBox.Text;

                    //string tempPass =RMSGlobal.Encrypt(PasswordTextBox.Text,true);

                    string tempPass = PasswordTextBox.Text;

                    if (!tempPass.Equals(ConfirmPassTextBox.Text))
                    {
                        MessageBox.Show("Given Password does not match with confirmed password.");
                        PasswordTextBox.Clear();
                        ConfirmPassTextBox.Clear();
                        return;
                    }
                    else
                    {
                        tempUser.Password = tempPass;

                      //  tempUser.Type = UserTypeComboBox.SelectedIndex;
                         tempUser.Type = CUserConstant.GetUSerConstant(UserTypeComboBox.Text);

                        if (GenderComboBox.SelectedIndex == 0) tempUser.Gender = "Male";
                        else if (GenderComboBox.SelectedIndex == 1) tempUser.Gender = "Female";

                        if (ActiveRadioButton.Checked) tempUser.Status = 1;
                        else if (InActiveRadioButton.Checked) tempUser.Status = 0;

                        CUserAccess tempUserAccess = new CUserAccess();
                        if (OpenDrawerCheckBox.Checked) tempUserAccess.OpenDrawer = 1;
                        if (VoidCheckBox.Checked) tempUserAccess.VoidTable = 1;
                        if (TransferCheckBox.Checked) tempUserAccess.TransferTable = 1;
                        if (MergeCheckBox.Checked) tempUserAccess.MergeTable = 1;
                        if (UnlockCheckBox.Checked) tempUserAccess.UnlockTable = 1;
                        if (ReviewCheckBox.Checked) tempUserAccess.ReviewTransaction = 1;
                        if (ViewCheckBox.Checked) tempUserAccess.ViewReport = 1;
                        if (TillCheckBox.Checked) tempUserAccess.TillReporting = 1;
                        if (ExitCheckBox.Checked) tempUserAccess.ExitRms = 1;
                        if (CustomersCheckBox.Checked) tempUserAccess.Customers = 1;
                        if (UsersCheckBox.Checked) tempUserAccess.Users= 1;
                        if (BookingCheckBox.Checked) tempUserAccess.Booking = 1;
                        if (DepositCheckBox.Checked) tempUserAccess.Deposit = 1;
                        if (UpdateItemCheckBox.Checked) tempUserAccess.UpdateItems = 1;
                        if (chkRemoveItems.Checked) tempUserAccess.RemoveItems = 1;
                        if (chkLogRegister.Checked) tempUserAccess.LogRegister = 1;

                        if (chkProcessTime.Checked) tempUserAccess.ProcessDeliveryTime= 1;
                        if (chkManageKitchenText.Checked) tempUserAccess.KitchenText = 1;

                        if (chkSettings.Checked) tempUserAccess.SystemSettings = 1;

                        tempUser.UserAccess = tempUserAccess;

                        CUserManager tempUserManager = new CUserManager();
                        CResult tempResult = new CResult();
                        if (m_sOpType.Equals("Add")) tempResult = tempUserManager.AddUser(tempUser);
                        else if (m_sOpType.Equals("Update"))
                        {
                            tempUser.UserID = m_oUserInfo.UserID;
                            tempResult = tempUserManager.UpdateUser(tempUser);
                        }
                        else ;

                        if (tempResult.IsSuccess)
                        {
                            Form tempMainForm = CFormManager.Forms.Pop();
                            tempMainForm.Show();
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(tempCheckForValidation.Message);
                    ClearTextBoxes();
                    return;
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #12
0
        /*public CResult AddUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                int iTempInt = 0;

                bool bIsRead = false;

                bool bTempFlag = false;

                bTempFlag = CheckUser(inUser);

                if (bTempFlag)
                {
                    oResult.Message = " User exists with this user name. Please write another name.";
                }

                else
                {

                    inUser.UserName = inUser.UserName.Replace("''", "'");
                    inUser.UserName = inUser.UserName.Replace("'", "''");

                    this.OpenConnection();
                    string sSql = String.Format(SqlQueries.GetQuery(Query.AddUser), inUser.UserName, inUser.Password, inUser.Type, inUser.Status, inUser.Gender);

                    this.ExecuteNonQuery(sSql);

                    sSql = SqlQueries.GetQuery(Query.ScopeIdentity);

                    IDataReader oReader = this.ExecuteReader(sSql);
                    if (oReader != null)
                    {
                        bIsRead = oReader.Read();
                        if (bIsRead)
                        {

                            inUser.UserID = Int32.Parse(oReader[0].ToString());
                        }
                        oReader.Close();
                    }

                    if (inUser.UserAccess.OpenDrawer == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "OpenDrawer");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);
                                }
                            }
                            oReader.Close();

                        }

                    }

                    if (inUser.UserAccess.ReviewTransaction == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ReviewTransaction");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);
                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.VoidTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "VoidTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);
                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ViewReport == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ViewReport");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);
                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TransferTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TransferTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TillReporting == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TillReporting");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.MergeTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "MergeTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ExitRms == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ExitRMS");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.UnlockTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "UnlockTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    oResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemInsert()", ex);

                oResult.Message = "Could not add User. Please try again";

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }

        public CResult UpdateUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = false;

                bool bIsRead = false;

                IDataReader oReader = null;

                int iTempInt = 0;

                bTempFlag = CheckUserForUpdate(inUser);

                if (bTempFlag)
                {
                    oResult.Message = " User exists with this user name. Please write another name.";
                }

                else
                {
                    //this.OpenConnection();

                    inUser.UserName = inUser.UserName.Replace("''", "'");
                    inUser.UserName = inUser.UserName.Replace("'", "''");

                    this.OpenConnectionWithTransection();

                    string sSql = string.Format(SqlQueries.GetQuery(Query.UpdateUser), inUser.UserName, inUser.Password, inUser.Type, inUser.Status, inUser.Gender, inUser.UserID);
                    this.ExecuteNonQuery(sSql);

                    sSql = String.Format(SqlQueries.GetQuery(Query.DeleteAllButtonAccess), inUser.UserID);

                    this.ExecuteNonQuery(sSql);

                    if (inUser.UserAccess.OpenDrawer == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "OpenDrawer");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();

                        }

                    }

                    if (inUser.UserAccess.ReviewTransaction == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ReviewTransaction");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.VoidTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "VoidTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ViewReport == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ViewReport");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TransferTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TransferTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TillReporting == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TillReporting");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.MergeTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "MergeTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ExitRms == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ExitRMS");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.UnlockTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "UnlockTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    this.CommitTransection();

                    oResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemDelete()", ex);

                this.RollBackTransection();
            }
            finally
            {
                this.CloseConnection();
            }

            return oResult;
        }*/
        public CResult DeleteUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                //this.OpenConnection();

                this.OpenConnectionWithTransection();

                string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteUser), inUser.UserID);
                this.ExecuteNonQuery(sSql);

                sSql = string.Format(SqlQueries.GetQuery(Query.DeleteAllButtonAccess), inUser.UserID);
                this.ExecuteNonQuery(sSql);

                oResult.IsSuccess = true;

                this.CommitTransection();
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemDelete()", ex);

                oResult.IsException = true;

                this.RollBackTransection();

            }
            finally
            {
                this.CloseConnection();
            }

            return oResult;
        }
예제 #13
0
        private Transaction ReaderToReadInventoryTransaction(IDataReader aReader)
        {
            Transaction aTransaction=new Transaction();
               InventoryCategory aCategory = new InventoryCategory();
               InventoryItem aItem = new InventoryItem();
               Unit aUnit = new Unit();
               CUserInfo aCUserInfo = new CUserInfo();
               Stock aStock = new Stock();

               try
               {
               aTransaction.TransactionId = Convert.ToInt32(aReader["transaction_id"]);

               }
               catch
               {

               }

               try
               {
               aTransaction.TransactionType = (aReader["transaction_type"]).ToString();

               }
               catch
               {

               }
               try
               {
               aTransaction.TransactionDate = Convert.ToDateTime((aReader["date"]));

               }
               catch
               {

               }

               try
               {
               aTransaction.TransactionAmount = Convert.ToDouble(aReader["total_price"]);

               }
               catch
               {

               }
               try
               {
               aTransaction.DamageReport = (aReader["damage_report"]).ToString();

               }
               catch
               {

               }

               try
               {
               aCategory.CategoryId = Convert.ToInt32(aReader["category_id"]);

               }
               catch
               {

               }
               try
               {

               aCategory.CategoryName = aReader["category_name"].ToString();
               }
               catch
               {
               }

               try
               {
               aItem.ItemId = Convert.ToInt32(aReader["item_id"]);

               }
               catch
               {

               }
               try
               {
               aItem.ItemName = (aReader["item_name"]).ToString();

               }
               catch
               {

               }

               try
               {
               aUnit.UnitName = (aReader["unit"]).ToString();

               }
               catch
               {
               }
               try
               {
               aCUserInfo.UserName = ((aReader["user_name"])).ToString();

               }
               catch
               {
               }

               try
               {
               aCUserInfo.UserName = ((aReader["user_name"])).ToString();

               }
               catch
               {
               }
               try
               {
               aStock.Stocks = Convert.ToDouble(aReader["quantity"]);

               }
               catch
               {
               }
               try
               {
               aStock.UnitPrice = Convert.ToDouble(aReader["unit_price"]);

               }
               catch
               {
               }

               aTransaction.Category = aCategory;
               aTransaction.Item = aItem;
               aTransaction.Unit = aUnit;
               aTransaction.UserInfo = aCUserInfo;
               aTransaction.Stock = aStock;
               return aTransaction;
        }
예제 #14
0
파일: LoginForm.cs 프로젝트: Jusharra/RMS
        private void ProcessLogin()
        {
            try
            {
                CCommonConstants objCommonConstant = ConfigManager.GetConfig<CCommonConstants>();

                CDalConfig objDalConstant = ConfigManager.GetConfig<CDalConfig>();

                CUserManager tempUserManager = new CUserManager();
                CLogin objLogin = new CLogin();
                CUserInfo objUserInfo = new CUserInfo();

                //objUserInfo.UserName = UserLabel.Text.Trim();

                //objUserInfo.Password = LoginTextBox.Text.Trim();

                objLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), objCommonConstant.RemoteURL);

                CResult objResult = objLogin.ProcessAdminLogin(objUserInfo);

                if (objResult.IsSuccess && objResult.Data != null)
                {
                    CUserLogin objUserLogin = (CUserLogin)objResult.Data;

                    objCommonConstant.UserInfo = objUserLogin.UserInfo;

                    objDalConstant.ConnectionString = objUserLogin.ConnectionStr;
                    RMSGlobal.LogInUserName = objCommonConstant.UserInfo.UserName;

                    objCommonConstant.DBConnection = objUserLogin.ConnectionStr;

                    RMSAdminMdiForm objParent = new RMSAdminMdiForm();  //Previous
                    objParent.Show();
                    this.Hide();
                }
                else
                {
                    //g_ErrorLabel.Show();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle,
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #15
0
        public CResult GetUser(CUserInfo inCat)
        {
            CResult oResult = new CResult();
            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.getUserByID), inCat.UserID);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        inCat = ReaderToUserInfo(oReader);

                        oResult.Data = inCat;

                        oResult.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #16
0
파일: CLogin.cs 프로젝트: Jusharra/RMS
        public CResult ProcessLogout(CUserInfo inUserInfo)
        {
            CUserManager oManager = new CUserManager();
            CResult oResult = oManager.LogoutUser(inUserInfo);

            if (oResult.IsSuccess && oResult.Data != null)
            {

            }
            return oResult;
        }
예제 #17
0
        private bool CheckUserForUpdate(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = String.Format(SqlQueries.GetQuery(Query.CheckDupUserForUpdate), inUser.UserName, inUser.UserID);

                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        if (oReader["user_id"] != null)
                        {
                            int iTemp = Int32.Parse(oReader["user_id"].ToString());

                            return true;
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemInsert()", ex);
            }
            finally
            {
                this.CloseConnection();
            }
            return false;
        }
예제 #18
0
 public void UserUpdate(CUserInfo oUser)
 {
 }
예제 #19
0
 public void UserInsert(CUserInfo oUser)
 {
 }
예제 #20
0
 public void UserDelete(CUserInfo oUser)
 {
 }
예제 #21
0
        public CUserInfo GetUserInfoByUsername(String inUsername)
        {
            CUserInfo oUserInfo = new CUserInfo();
            inUsername = inUsername.Replace("''", "'");
            inUsername = inUsername.Replace("'", "''");
            try
            {
                this.OpenConnection();
                string sSql = String.Format(SqlQueries.GetQuery(Query.UserInfoByUsername), inUsername);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        oUserInfo = ReaderToUser(oReader);

                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in GetAllUser()", LogLevel.Error, "Database");
                if (ex.GetType().Equals(typeof(SqlException)))
                {
                    SqlException oSQLEx = ex as SqlException;
                    if (oSQLEx.Number != 7619)
                        throw new Exception("Exception occured at GetAllUser()", ex);
                }
                else
                {
                    throw new Exception("Exception occure at GetAllUser()", ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return oUserInfo;
        }
예제 #22
0
파일: CLogin.cs 프로젝트: Jusharra/RMS
        public CResult ProcessLogin(CUserInfo inUserInfo)
        {
            CResult oNewResult = new CResult();
            try
            {
                CUserManager oManager = new CUserManager();
                CResult oResult = oManager.LoginUser(inUserInfo);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    CUserInfo oUser = (CUserInfo)oResult.Data;
                    CResult oResult2 = oManager.GetUserAccess(oUser);
                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        CUserAccess oUserAccess = (CUserAccess)oResult2.Data;

                        oUser.UserAccess = oUserAccess;

                        CUserLogin oUserLogin = new CUserLogin();

                        oUserLogin.UserInfo = oUser;

                        CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>();

                        String tempConnStr = oTempDal.ConnectionString;

                        oUserLogin.ConnectionStr = tempConnStr;

                        oNewResult.Data = oUserLogin;

                        oNewResult.IsSuccess = true;

                    }
                }
            }
            catch (Exception ex)
            {
            }
            return oNewResult;
        }
예제 #23
0
        public CResult AddUser(CUserInfo inUser)
        {
            CResult oResult = new CResult();

            try
            {
                int iTempInt = 0;

                bool bIsRead = false;

                bool bTempFlag = false;

                bTempFlag = CheckUser(inUser);

                if (bTempFlag)
                {
                    oResult.Message = " User exists with this user name. Please write another name.";
                }

                else
                {

                    inUser.UserName = inUser.UserName.Replace("''", "'");
                    inUser.UserName = inUser.UserName.Replace("'", "''");

                    this.OpenConnection();
                    string sSql = String.Format(SqlQueries.GetQuery(Query.AddUser), inUser.UserName, inUser.Password, inUser.Type, inUser.Status, inUser.Gender);

                    this.ExecuteNonQuery(sSql);

                    sSql = SqlQueries.GetQuery(Query.ScopeIdentity);

                    IDataReader oReader = this.ExecuteReader(sSql);
                    if (oReader != null)
                    {
                        bIsRead = oReader.Read();
                        if (bIsRead)
                        {

                            inUser.UserID = Int32.Parse(oReader[0].ToString());
                        }

                        oReader.Close();
                    }

                    if (inUser.UserAccess.OpenDrawer == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "OpenDrawer");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();

                        }

                    }

                    if (inUser.UserAccess.ReviewTransaction == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ReviewTransaction");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.VoidTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "VoidTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ViewReport == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ViewReport");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TransferTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TransferTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.TillReporting == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "TillReporting");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.MergeTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "MergeTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.ExitRms == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "ExitRMS");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.UnlockTable == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "UnlockTable");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.Booking == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "Booking");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.Users == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "Users");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.Deposit == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "Deposit");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.Customers == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "Customers");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    if (inUser.UserAccess.UpdateItems == 1)
                    {
                        sSql = String.Format(SqlQueries.GetQuery(Query.GetButtonIDByName), "UpdateItems");

                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {

                            bIsRead = oReader.Read();
                            if (bIsRead)
                            {

                                if (oReader["button_id"] != null)
                                {
                                    iTempInt = Int32.Parse(oReader["button_id"].ToString());
                                    oReader.Close();

                                    sSql = String.Format(SqlQueries.GetQuery(Query.AddButtonAccess), inUser.UserID, iTempInt);

                                    this.ExecuteNonQuery(sSql);

                                }
                            }

                            oReader.Close();
                        }

                    }

                    oResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemInsert()", ex);

                oResult.Message = "Could not add User. Please try again";

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #24
0
        private void TransactionWhenProfessionalPackageIsActive()
        {
            InventoryItem aItem = new InventoryItem();
            aItem = (InventoryItem)itemNamecomboBox.SelectedItem;
            InventoryCategory aInventoryCategory = new InventoryCategory();
            aInventoryCategory = (InventoryCategory)categoryNamecomboBox.SelectedItem;

            Stock aStock = new Stock();
            StockBLL aStockBll = new StockBLL();
            string transactiontype = transactionTypecomboBox.SelectedItem.ToString();
            Transaction aTransaction = new Transaction();
            aTransaction.TransactionDate = DateTime.Now;
            aTransaction.Item = aItem;
            aTransaction.Category = aInventoryCategory;
            aTransaction.TransactionType = transactiontype;
            CUserInfo aUserInfo = new CUserInfo();
            aUserInfo.UserName = RMSGlobal.LogInUserName;
            aTransaction.UserInfo = aUserInfo;
            string sr = string.Empty;
            if (transactiontype == "Damage_in_Stock")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemid(aItem.ItemId);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item = aItem;
                        aStock.Category = aInventoryCategory;
                        aTransaction.Stock = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.DamageInStock(aTransaction);
                        ShowAndClear(sr);
                    }
                    else
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                }
                else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
            }

            if (transactiontype == "Send_to_Kitchen")
            {
                aStock = aStockBll.GetStockByItemid(aItem.ItemId);

                if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0))
                {
                    aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                    aStock.Item = aItem;
                    aStock.Category = aInventoryCategory;
                    aTransaction.Stock = aStock;
                    TransactionBLL aBll = new TransactionBLL();
                    sr = aBll.SendToKitchen(aTransaction);
                    ShowAndClear(sr);
                }
                else MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to " + aStock.Stocks + " " + unittypelabel.Text);
            }

            //aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);
            if (transactiontype == "Return_from_Kitchen")
            {
                aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0))
                {
                    aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                    aStock.Item = aItem;
                    aStock.Category = aInventoryCategory;
                    aTransaction.Stock = aStock;
                    TransactionBLL aBll = new TransactionBLL();
                    sr = aBll.ReturnFromKitchen(aTransaction);
                    ShowAndClear(sr);
                }
                else MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to " + aStock.Stocks + " " + unittypelabel.Text);
            }

            if (transactiontype == "Damage_in_kitchen")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item = aItem;
                        aStock.Category = aInventoryCategory;
                        aTransaction.Stock = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.DamageInKitchen(aTransaction);
                        ShowAndClear(sr);
                    }
                    else
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                }
                else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
            }

            if (transactiontype == "Stock_Out_In_Kitchen")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item = aItem;
                        aStock.Category = aInventoryCategory;
                        aTransaction.Stock = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.SendOutInKitchen(aTransaction);

                        StockDAO aStockDao=new StockDAO();
                        aStockDao.InsertOrUpdateSaleRawmaterialsReport(aTransaction.Item.ItemId, Convert.ToDouble(quantitytextBox.Text),aStock.UnitPrice);
                        ShowAndClear(sr);
                    }
                    else
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                }
                else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
            }
        }
예제 #25
0
파일: CUserLogin.cs 프로젝트: Jusharra/RMS
 public CUserLogin()
 {
     m_oUserInfo = new CUserInfo();
     m_sConnectionStr = String.Empty;
 }
예제 #26
0
        private void savePurchasebutton_Click(object sender, EventArgs e)
        {
            try
            {

                if (expiredateTimePicker.Value.Date == DateTime.Now.Date)
                {
                    DialogResult result = MessageBox.Show("Do you want to Empty Expire Date?", "Confirmation",
                                                          MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {

                    }
                    else if (result == DialogResult.No)
                    {
                        return;
                    }

                }

                if (pricetextBox.Text.Length != 0 && paidPricetextBox.Text.Length != 0 && quantitytextBox.Text.Length != 0)
                {
                    InventoryPurchase aInventoryPurchase = new InventoryPurchase();
                    InventoryCategory aCategory = new InventoryCategory();
                    InventoryItem aItem = new InventoryItem();
                    Supplier aSupplier = new Supplier();
                    Supplier aaSupplier = new Supplier();
                    Unit aUnit = new Unit();

                    //Add for purchase record
                    aCategory = (InventoryCategory) categoryNamecomboBox.Items[categoryNamecomboBox.SelectedIndex];

                    SupplierBLL aSupplierBll = new SupplierBLL();
                    aSupplier = aSupplierBll.GetSupplierByid(Convert.ToInt32(supplierNamecomboBox.SelectedValue));
                   // aSupplier = (Supplier) supplierNamecomboBox.Items[supplierNamecomboBox.SelectedIndex];
                    if (aSupplier.PaidAmount > aSupplier.TotalAmount)
                    {
                        aSupplier.AdvanceAmount = aSupplier.PaidAmount - aSupplier.TotalAmount;
                    }
                    else aSupplier.DueAmount = aSupplier.TotalAmount - aSupplier.PaidAmount;

                    aItem = (InventoryItem) itemNamecomboBox.Items[itemNamecomboBox.SelectedIndex];
                    aInventoryPurchase.Quantity = Convert.ToDouble(quantitytextBox.Text);
                    aInventoryPurchase.Price = Convert.ToDouble(pricetextBox.Text);
                    aInventoryPurchase.Date = DateTime.Now;
                    aInventoryPurchase.Category = aCategory;
                    aInventoryPurchase.Item = aItem;
                    aaSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text);
                    aInventoryPurchase.Supplier = aaSupplier;
                    if (((aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text) -
                          (Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount))) >= 0)
                        aInventoryPurchase.Supplier.DueAmount = aSupplier.DueAmount +
                                                                Convert.ToDouble(pricetextBox.Text) -
                                                                (Convert.ToDouble(paidPricetextBox.Text) +
                                                                 aSupplier.AdvanceAmount);
                    else aInventoryPurchase.Supplier.DueAmount = 0.0;
                    if (((Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount) -
                         (aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text))) >= 0)
                    {
                        aInventoryPurchase.Supplier.AdvanceAmount = (Convert.ToDouble(paidPricetextBox.Text) +
                                                                     aSupplier.AdvanceAmount) -
                                                                    (aSupplier.DueAmount +
                                                                     Convert.ToDouble(pricetextBox.Text));
                    }
                    else aInventoryPurchase.Supplier.AdvanceAmount = 0.0;
                    aInventoryPurchase.Supplier.Name = aSupplier.Name;
                    aInventoryPurchase.Supplier.SupplierId = aSupplier.SupplierId;
                    aUnit.UnitName = unittypelabel.Text;
                    aInventoryPurchase.Unit = aUnit;
                    CUserInfo aUserInfo= new CUserInfo();
                    aUserInfo.UserName= RMSGlobal.LogInUserName;
                    aInventoryPurchase.PaymentType= paymentTypecomboBox.SelectedItem.ToString();
                    aInventoryPurchase.CUserInfo= aUserInfo;
                    if (expiredateTimePicker.Value.Date == DateTime.Now.Date)
                    {

                    }
                    else
                    {
                        aInventoryPurchase.ExpireDate = expiredateTimePicker.Value.Date;
                    }

                    string res = string.Empty;

                    InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL();
                    res = aInventoryPurchaseBll.InsertPurchase(aInventoryPurchase);

                    if(res=="Purchase Insert Sucessfully")
                    {
                        //Add for Supplier Update
                        aSupplier.TotalAmount += Convert.ToDouble(pricetextBox.Text);
                        aSupplier.PaidAmount += Convert.ToDouble(paidPricetextBox.Text);

                        aSupplierBll.UpdateSupplierForPurchase(aSupplier);

                        //Add for Supplier payment report
                        Supplier paymentSupplier=new Supplier();
                        paymentSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text);
                        paymentSupplier.TotalAmount = Convert.ToDouble(pricetextBox.Text);
                        paymentSupplier.SupplierId = aSupplier.SupplierId;
                        paymentSupplier.PaymentType = paymentTypecomboBox.SelectedItem.ToString();
                        aSupplierBll.InsertIntosupplier_payment_reportForSupplierPaymentTrack(paymentSupplier);

                        //Add for stock update
                        Stock aStock=new Stock();
                        aStock.Category = aCategory;
                        aStock.Item = aItem;
                        aStock.Unit = aUnit;
                        aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                        aStock.UnitPrice = Convert.ToDouble(pricetextBox.Text)/aStock.Stocks;
                        StockBLL aStockBll=new StockBLL();
                        aStockBll.InsertStockOrUpdate(aStock);

                        purchaseActionlabel.Visible = true;
                        purchaseActionlabel.Text = res;
                        Clear();
                    }else
                    {
                        purchaseActionlabel.Visible = true;
                        purchaseActionlabel.Text = res;
                    }

                }else
                {
                    purchaseActionlabel.Visible = true;
                    purchaseActionlabel.Text = "Please Check Your Input";
                }

            }
            catch
            {
                MessageBox.Show("Try Again May Be Your Given Input Format Not Correct Please Given Again ");

            }
        }
예제 #27
0
        private void dgvUsers_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 6)
                {
                    Int32 userID = Convert.ToInt32("0" + dgvUsers.Rows[e.RowIndex].Cells[0].Value);

                    UpdateUserCtl objUpdateUser = new UpdateUserCtl(userID);
                    objUpdateUser.Parent = this.ParentForm;
                    UserControlManager.UserControls.Push(this);
                    Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"];

                    string s = pnl.Name;

                    objUpdateUser.ParentForm.Controls[s].Controls.Clear();
                    objUpdateUser.ParentForm.Controls[s].Controls.Add(objUpdateUser);
                }

                else if (e.ColumnIndex == 7)
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected user?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Int32 userID = 0;

                        bool bTempBool = Int32.TryParse(dgvUsers.Rows[e.RowIndex].Cells[0].Value.ToString(), out userID);

                        if (bTempBool)
                        {
                            CUserInfo objUserInfo = new CUserInfo();

                            objUserInfo.UserID = userID;
                            CUserManager oManager = new CUserManager();

                            CResult oResult = oManager.DeleteUser(objUserInfo);

                            if (oResult.IsSuccess)
                            {
                                dgvUsers.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #28
0
        public CResult GetUserAccess(CUserInfo inCat)
        {
            CResult oResult = new CResult();

            CUserAccess oUserAccess = new CUserAccess();
            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.GetUserAccess), inCat.UserID);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    //if (oReader.Read())
                    //    oItem = ReaderToUserAccess(oReader);

                    while (oReader.Read())
                    {
                        oUserAccess = ReaderToUserAccess(oReader, oUserAccess);
                        //oItemList.Add(oItem);
                    }

                    oResult.Data = oUserAccess;

                    oResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #29
0
        public CResult LoginAdminUser(CUserInfo inCat)
        {
            CResult oResult = new CResult();

            CUserInfo oUser = new CUserInfo();
            try
            {
                this.OpenConnection();

                string sSql = string.Format(SqlQueries.GetQuery(Query.LoginUser), inCat.UserName);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {

                    if (oReader.Read())
                    {

                        oUser = ReaderToUserInfo(oReader);

                        if ((!oUser.Password.Equals(String.Empty)) && oUser.Password.Equals(inCat.Password) && oUser.Status != 0)
                        {
                           oResult.IsSuccess = true;

                           oResult.Data = oUser;

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in LoginUser() in CUserInfoDAO ", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
예제 #30
0
 public CUserInfoForm(String inOpType, CUserInfo inUserInfo)
 {
     InitializeComponent();
     m_oUserInfo = inUserInfo;
     m_sOpType = inOpType;
 }
예제 #31
0
파일: CUserLogin.cs 프로젝트: Jusharra/RMS
 public CUserLogin()
 {
     m_oUserInfo      = new CUserInfo();
     m_sConnectionStr = String.Empty;
 }