Exemple #1
0
        public AddManager(Manager_details obj)
        {
            InitializeComponent();

            if (obj == null)
            {
                btnUpdate.Enabled = false;
            }
            else
            {
                btnSave.Enabled = false;
                managerdetailsBindingSource.DataSource = obj;
                pbM.Image = ci.ConvertByteToImage(obj.Image);
            }
        }
        public AddSalesman(Salesman_Details obj)
        {
            InitializeComponent();

            if (obj == null)
            {
                btnUpdate.Enabled = false;
            }
            else
            {
                btnSave.Enabled = false;
                salesmanDetailsBindingSource.DataSource = obj;
                pbS.Image = ci.ConvertByteToImage(obj.Image);
            }
        }
        public AddProduct(CMS.Data.Product_Details obj)
        {
            InitializeComponent();

            if (obj == null)
            {
                btnUpdate.Enabled = false;
            }
            else
            {
                txtPStock.ReadOnly = true;
                btnSave.Enabled    = false;
                productDetailsBindingSource.DataSource = obj;
                pbP.Image = ci.ConvertByteToImage(obj.Image);
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            CMS_DBEntities context = new CMS_DBEntities();
            var            obj     = context.User_Details.FirstOrDefault(u => u.Username.Equals(txtUsername.Text) && u.Password.Equals(txtPassword.Text));

            if (obj == null)
            {
                MetroFramework.MetroMessageBox.Show(this, "Invalid username or password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsername.Focus();
                return;
            }

            var up = new UserProfile()
            {
                ID        = obj.U_ID,
                Name      = obj.U_Name,
                UserName  = obj.Username,
                Password  = obj.Password,
                User_Type = obj.User_Type,
                UImage    = ci.ConvertByteToImage(obj.Image)
            };

            LoginHelper.UserProfile = up;
            lblWelcome.Text         = LoginHelper.UserProfile.Name;
            lblDate.Text            = DateTime.Now.ToString();
            if (LoginHelper.UserProfile.UImage != null)
            {
                pbProfile.Image = LoginHelper.UserProfile.UImage;
            }
            pnlMenu.Show();
            pnlCurrentUser.Show();
            pnlMain.Controls.Clear();

            switch (obj.User_Type)
            {
            case (int)EnumCollection.UserTypeEnum.Admin:
                lblUDetails.Text   = "Admin";
                pbAdmin.Enabled    = true;
                pbManagers.Enabled = true;
                break;

            case (int)EnumCollection.UserTypeEnum.SalesManager:
                lblUDetails.Text    = "Manager";
                pbPEntry.Enabled    = true;
                pbPOrder.Enabled    = true;
                pbPReturn.Enabled   = true;
                pbSalesmen.Enabled  = true;
                pbSuppliers.Enabled = true;
                break;

            case (int)EnumCollection.UserTypeEnum.Salesman:
                lblUDetails.Text   = "Salesman";
                pbPEntry.Enabled   = true;
                pbPReturn.Enabled  = true;
                pbProducts.Enabled = true;
                break;

            default:
                break;
            }
        }