Ejemplo n.º 1
0
        private bool GetBuyData(GridView view)
        {
            try
            {
                sBuyId = Convert.ToInt32(view.GetFocusedRowCellValue("BuyId"));

                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetBuy().Where(o => o.BuyId == sBuyId).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetBuy_Result dt in query)
                        {
                            strBuyNumber           = dt.BuyNumber;
                            TxtBuyNumber.Text      = dt.BuyNumber;
                            DtBuyDate.DateTime     = dt.BuyDate.Value;
                            sCustomerId            = dt.CustomerId.Value;
                            TxtCustomerName.Text   = dt.CustomerName;
                            SpinSubTotal.Value     = dt.SubTotal.Value;
                            SpinDownValue.Value    = dt.DownValue.Value;
                            SpinNetTotal.Value     = dt.NetTotal.Value;
                            SpinSetOffValue.Value  = dt.SetOffValue.Value;
                            SpinValueBalance.Value = dt.ValueBalance.Value;
                            sActive        = dt.Active.Value;
                            sProductTypeId = dt.ProductTypeId.Value;
                        }

                        GetCustomer(sCustomerId);
                        GetBuyProduct(sBuyId);
                        LoadProductType(sProductTypeId);
                        GetValueBalance(sCustomerId);

                        if (sActive == false)
                        {
                            BtnEditBuy.Enabled = false;
                            //if (ClassProperty.IsOpenBuy == false)
                            //{
                            //    BtnRefBuy.Visible = true;
                            //}
                        }
                        else
                        {
                            BtnEditBuy.Enabled = true;
                            //BtnRefBuy.Visible = false;
                        }
                    }
                    else
                    {
                        ClearData();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private bool GetData(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetUsers().Where(o => o.UserId == id).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetUsers_Result dt in query)
                        {
                            userName          = dt.UserName;
                            strUserName       = dt.UserName;
                            roleId            = dt.UserTypeId.Value;
                            TxtUserName.Text  = dt.UserName;
                            TxtPassword.Text  = SQLData.DecryptString(dt.Password);
                            TxtFirstName.Text = dt.FirstName;
                            TxtLastName.Text  = dt.LastName;
                            SLRole.EditValue  = roleId;
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool GetTerminal(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetTerminal().Where(o => o.TerminalId == id).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetTerminal_Result dt in query)
                        {
                            ClassProperty.StrTerminalId  = dt.TerminalId;
                            ClassProperty.MachineName    = dt.TerminalName;
                            ClassProperty.EnableTerminal = dt.Active.Value;
                        }
                    }
                    else
                    {
                        ClassProperty.StrTerminalId  = 0;
                        ClassProperty.MachineName    = "";
                        ClassProperty.EnableTerminal = false;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 4
0
        private bool GetGridData(string tex)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    if (tex.Trim() == "" || tex.Length <= 0)
                    {
                        var query = context.spt_GetUsers().Where(o => o.Active == true).ToList();
                        GridUsers.DataSource = query;
                    }
                    else
                    {
                        var query = context.spt_GetUsers().Where(o => o.Active == true && o.UserName == tex ||
                                                                 o.FirstName == tex || o.LastName == tex).ToList();
                        GridUsers.DataSource = query;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 5
0
        private bool CheckData(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetUsers().Where(o => o.UserId == id).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetUsers_Result dt in query)
                        {
                            userId = dt.UserId;
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 6
0
        private bool GetUserData(int UserId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetUsers().Where(o => o.UserId == UserId).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetUsers_Result dt in query)
                        {
                            ClassProperty.permisUserNm = dt.UserName;
                            ClassProperty.permisRole   = dt.RoleName;
                            ClassProperty.permisRoleId = dt.UserTypeId.Value;

                            lblUserName.Text = "ยินดีต้อนรับ : " + ClassProperty.permisUserNm;
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 7
0
        private bool GetSale()
        {
            try
            {
                string text = TxtSearch.Text.Trim();

                using (var context = new RubberSoftEntities())
                {
                    SetTime();

                    if (text == "")
                    {
                        var query = context.spt_GetSale().Where(o => o.SaleDate >= StartDate &&
                                                                o.SaleDate <= EndDate).ToList();

                        GridSale.DataSource = query;
                    }
                    else
                    {
                        var query = context.spt_GetSale().Where(o => o.SaleDate >= StartDate &&
                                                                o.SaleDate <= EndDate && (o.SaleNumber.Contains(text) ||
                                                                                          o.CustomerName.Contains(text))).ToList();

                        GridSale.DataSource = query;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 8
0
        private bool GetData(int sRoleId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetRoles().Where(o => o.RoleId == sRoleId).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetRoles_Result dt in query)
                        {
                            strRoleName          = dt.RoleName;
                            TxtRoleName.Text     = dt.RoleName;
                            strRoleFullName      = dt.RoleFullName;
                            TxtRoleFullName.Text = dt.RoleFullName;
                        }

                        GetAuthorized(sRoleId);
                    }
                    else
                    {
                        ClearValues();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 9
0
        private bool GetCustomer(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetCustomer().Where(o => o.CustomerId == id).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetCustomer_Result dt in query)
                        {
                            TxtLicensePlate.Text = dt.LicensePlate;
                            TxtPhone.Text        = dt.Phone;
                            TxtAddress.Text      = dt.CustomerAddress;
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 10
0
        public bool CheckTerminal(string name)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetTerminal().Where(o => o.MachineName == name).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetTerminal_Result dt in query)
                        {
                            ClassProperty.StrTerminalId = dt.TerminalId;
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 11
0
        private bool GetSaleData(GridView view)
        {
            try
            {
                sSaleId = Convert.ToInt32(view.GetFocusedRowCellValue("SaleId"));

                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetSale().Where(o => o.SaleId == sSaleId).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetSale_Result dt in query)
                        {
                            strSaleNumber          = dt.SaleNumber;
                            TxtSaleNumber.Text     = dt.SaleNumber;
                            DtSaleDate.DateTime    = dt.SaleDate.Value;
                            sCustomerId            = dt.CustomerId.Value;
                            TxtCustomerName.Text   = dt.CustomerName;
                            SpinSubTotal.Value     = dt.SubTotal.Value;
                            SpinDownValue.Value    = dt.DownValue.Value;
                            SpinNetTotal.Value     = dt.NetTotal.Value;
                            SpinSetOffValue.Value  = dt.SetOffValue.Value;
                            SpinValueBalance.Value = dt.ValueBalance.Value;
                            sActive        = dt.Active.Value;
                            sProductTypeId = dt.ProductTypeId.Value;
                        }

                        GetCustomer(sCustomerId);
                        GetSaleProduct(sSaleId);
                        LoadProductType(sProductTypeId);
                        GetValueBalance(sCustomerId);

                        if (sActive == false)
                        {
                            BtnCancelSale.Enabled = false;
                        }
                        else
                        {
                            BtnCancelSale.Enabled = true;
                        }
                    }
                    else
                    {
                        ClearData();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 12
0
        private bool GetData(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetCustomer().Where(o => o.CustomerId == id).ToList();
                    if (query.Count > 0)
                    {
                        foreach (spt_GetCustomer_Result dt in query)
                        {
                            TxtCustomerCode.Text    = dt.CustomerCode;
                            stCustomerCode          = dt.CustomerCode;
                            TxtCustomerName.Text    = dt.CustomerName;
                            stCustomerName          = dt.CustomerName;
                            TxtLicensePlate.Text    = dt.LicensePlate;
                            TxtPhone.Text           = dt.Phone;
                            TxtCustomerAddress.Text = dt.CustomerAddress;
                            stCustomerTypeId        = dt.CustomerTypeId.Value;
                            _IsDefault = dt.IsDefault;

                            if (_IsDefault == true)
                            {
                                LkCustomerTypes.EditValue = 0;
                                LkCustomerGroup.EditValue = 0;
                                SetDefaultCustomer(true);
                            }
                            else
                            {
                                LkCustomerTypes.EditValue = dt.CustomerTypeId;
                                LkCustomerGroup.EditValue = dt.CustomerGroupId;
                                SetDefaultCustomer(false);
                            }

                            SpinNetTotal.ReadOnly = true;
                            BtnAdjust.Enabled     = true;

                            LoadCustomerPrices(id);
                            GetValueBalance(id);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 13
0
        private bool AddOutStandingLog(decimal BeginOutstandingDebt, decimal OutstandingDebt, int RefId, int Status, int LogTypeId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_AddOutStandingLog(sCustomerId, BeginOutstandingDebt, OutstandingDebt, RefId, Status, LogTypeId);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 14
0
        private bool UpdateOutStandingBalance(decimal BeginDebt, decimal OutstandingDebt, int LastLogId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_UpdateOutStandingBalance(sCustomerId, BeginDebt, OutstandingDebt, LastLogId);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 15
0
        private bool DeleteData(int cid)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_DeleteCustomer(cid, ClassProperty.permisUserID);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 16
0
        public bool Addlog(int logtype, string logname, string logdetail, int userid, string ipmachhine, string machinename)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    context.spt_AddLog(logtype, logname, logdetail, userid, ipmachhine, machinename);
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 17
0
        public bool AddTerminal()
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    context.spt_AddTerminal(ClassProperty.GetCurrentName, ClassProperty.IPMachine, ClassProperty.MachineName, false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 18
0
        private bool UpdateData(bool active)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_UpdateUsers(userId, roleId, userName, passWord, firstName, lastName, active);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 19
0
        private bool UpdateData()
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_UpdateCustomer(sCustomerId, stCustomerTypeId, CustomerGroupId, sCustomerCode, sCustomerName,
                                                           TxtCustomerAddress.Text, TxtLicensePlate.Text, TxtPhone.Text, false, ClassProperty.permisUserID);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 20
0
        private bool AddWeightBalance(int PriceId, decimal BeginBalanceAmt, decimal WeightBalanceAmt, int LastLogId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_AddWeightBalance(sCustomerId, PriceId, BeginBalanceAmt,
                                                             WeightBalanceAmt, LastLogId);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 21
0
        public bool UpdateCustomerPrice(int CustomerId, int sPriceId, string PriceName, DateTime sSaleDate, decimal sSalePriceAdvance,
                                        double sWeightAmount, decimal sDeliveryPrice, bool IsDefault)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_UpdateCustomerPrice(sPriceId, PriceName, CustomerId, sSaleDate, sSalePriceAdvance,
                                                                sWeightAmount, sDeliveryPrice, IsDefault);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 22
0
        private bool AddTransactionLog(int PriceId, decimal BeginAmt, decimal WeightAmount_Raw,
                                       decimal WeightBalanceAmt, int RefId, int LogTypeId)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_AddTransactionLog(sCustomerId, PriceId, BeginAmt, WeightAmount_Raw,
                                                              WeightBalanceAmt, RefId, LogTypeId);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 23
0
        private bool GetRoles()
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    var query = context.spt_GetRoles().Where(o => o.Active == 1).ToList();
                    SLRole.Properties.DataSource    = query;
                    SLRole.Properties.DisplayMember = "RoleFullName";
                    SLRole.Properties.ValueMember   = "RoleId";
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 24
0
        private bool CheckDuplicate(int id)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    if (CheckData(id) == true)
                    {
                        //if (sCustomerName != stCustomerName)
                        //{
                        //    var query = context.spt_GetCustomer().Where(o => o.CustomerName == sCustomerName).ToList();
                        //    if (query.Count > 0)
                        //    {
                        //        XtraMessageBox.Show("ชื่อนี้มีในระบบแล้ว !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        //        return true;
                        //    }
                        //}
                    }
                    else
                    {
                        //if (sCustomerName != "")
                        //{
                        //    var query = context.spt_GetCustomer().Where(o => o.CustomerName == sCustomerName).ToList();
                        //    if (query.Count > 0)
                        //    {
                        //        XtraMessageBox.Show("ชื่อนี้มีในระบบแล้ว !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        //        return true;
                        //    }
                        //}
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 25
0
        public bool CheckRubberSoftConnection()
        {
            try
            {
                using (RubberSoftEntities db = new RubberSoftEntities())
                {
                    bool check = db.Database.Exists();
                    if (check == false)
                    {
                        db.Database.Connection.Close();
                        return(false);
                    }
                }

                return(true);
            }
            catch (SqlException __SqlException)
            {
                XtraMessageBox.Show(__SqlException.Message);
                return(false);
            }
        }
Ejemplo n.º 26
0
 private bool CheckData(int SaleId)
 {
     try
     {
         using (var context = new RubberSoftEntities())
         {
             var query = context.spt_GetSale().Where(o => o.SaleId == SaleId).ToList();
             if (query.Count > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 27
0
 private bool CheckDataOutStandingBalance(int id)
 {
     try
     {
         using (var context = new RubberSoftEntities())
         {
             var query = context.spt_GetOutStandingBalance().Where(o => o.CustomerId == id).ToList();
             if (query.Count > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 28
0
 private bool CheckDuplicate()
 {
     try
     {
         using (var context = new RubberSoftEntities())
         {
             var query = context.spt_GetUsers().Where(o => o.UserName == userName && o.Active == true).ToList();
             if (query.Count > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 29
0
        private bool CheckDuplicate(int Type)
        {
            try
            {
                using (var context = new RubberSoftEntities())
                {
                    if (Type == 1)
                    {
                        var ckRoleName = context.spt_GetRoles().Where(o => o.RoleName == stRoleName &&
                                                                      o.Active == 1).ToList();

                        if (ckRoleName.Count > 0)
                        {
                            return(false);
                        }
                    }

                    if (Type == 2)
                    {
                        var ckRoleFullName = context.spt_GetRoles().Where(o => o.RoleFullName == stRoleFullName &&
                                                                          o.Active == 1).ToList();

                        if (ckRoleFullName.Count > 0)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 30
0
        private bool Login()
        {
            try
            {
                if (SQLData.CheckRubberSoftConnection() == false || SQLData.CheckConnection() == false)
                {
                    XtraMessageBox.Show("ไม่สามารถเชื่อมต่อระบบได้", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                if (TxtUserName.Text.Trim() == "" || TxtPassword.Text == "")
                {
                    Alert();
                    return(false);
                }

                if (TxtUserName.Text.Trim() == SQLData.ID &&
                    TxtPassword.Text.Trim() == SQLData.DecryptString(SQLData.KEY))
                {
                    ClassProperty.permisUserID   = -1;
                    ClassProperty.permisUserNm   = SQLData.ID;
                    ClassProperty.permisRole     = "IT";
                    ClassProperty.permisRoleId   = -1;
                    ClassProperty.permisUserPass = TxtPassword.Text.Trim();

                    CheckLogin();
                }
                else
                {
                    if (ClassProperty.EnableTerminal == false)
                    {
                        XtraMessageBox.Show("เครื่องใช้งานไม่มีสิทธิ์เข้าใช้งานระบบ", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    using (var context = new RubberSoftEntities())
                    {
                        var query = context.spt_GetUsers().Where(o => o.UserName == TxtUserName.Text &&
                                                                 SQLData.DecryptString(o.Password) == TxtPassword.Text.Trim()).ToList();
                        if (query.Count > 0)
                        {
                            foreach (spt_GetUsers_Result dt in query)
                            {
                                ClassProperty.permisUserID   = dt.UserId;
                                ClassProperty.permisUserNm   = dt.UserName;
                                ClassProperty.permisRole     = dt.RoleName;
                                ClassProperty.permisRoleId   = dt.UserTypeId.Value;
                                ClassProperty.permisUserPass = TxtPassword.Text.Trim();

                                // 1-001	1 : สิทธิ์ใช้งานหน้าเข้าสู่ระบบ	เข้าสู่ระบบ
                                int AuthorizeId = 1;

                                if (SQLAuthorized.CheckAuthorized(ClassProperty.permisRoleId, AuthorizeId) == false)
                                {
                                    SQLAuthorized.AlertAuthorized("สิทธิ์ใช้งานหน้าเข้าสู่ระบบ", "ไม่มีสิทธิ์การใช้งานระบบ");
                                    return(false);
                                }

                                CheckLogin();
                            }
                        }
                        else
                        {
                            //XtraMessageBox.Show("ข้อมูลผู้ใช้งานมีปัญหา กรุณาติดต่อ IT !", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            Alert();
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
                return(false);
            }
        }