Esempio n. 1
0
        private void FillTreeView()
        {
            tvuser.Nodes.Clear();
            string query = "Select * from T_User order by UserName";
            List <Dictionary <string, string> > userlist = _dbconn.GetResultList(query, null);

            for (int i = 0; i < userlist.Count; ++i)
            {
                TreeNode usernode = new TreeNode();
                Dictionary <string, string> user = userlist[i];
                Snackboxx.Core.User         User = new Snackboxx.Core.User();
                User.userid       = user["UserID"];
                usernode.Text     = user["UserName"];
                User.username     = user["UserName"];
                User.loginname    = user["LoginName"];
                User.rest         = user["rest"];
                User.EMail        = user["EMail"];
                User.betragsLimit = user["BetragsLimit"];
                if (!string.IsNullOrEmpty(user["Password"]))
                {
                    User.Password = _crypt.DecryptMessage(user["Password"], _cryptstr);
                }
                User.UserRightID = user["UserRightID"];
                usernode.Tag     = User;
                tvuser.Nodes.Add(usernode);
            }
        }
Esempio n. 2
0
        private void btnaddcode_Click(object sender, EventArgs e)
        {
            try
            {
                UserCode Ucode = new UserCode();
                Ucode.userCode = tbscancode.Text;
                Ucode.Preis    = tbpreis.Text.Replace(",", ".");
                if (rbnTimeCode.Checked)
                {
                    Ucode.Issnackcode = false;
                }
                else
                {
                    Ucode.Issnackcode = true;
                }


                lbcodes.Items.Add(Ucode);
                if (!string.IsNullOrEmpty(tbuserid.Text))
                {
                    TreeNode            node = tvuser.SelectedNode;
                    Snackboxx.Core.User user = (Snackboxx.Core.User)node.Tag;
                    Ucode.UserID = user.userid;
                    if (user.usercodes == null)
                    {
                        user.usercodes = new List <UserCode>();
                    }
                    user.usercodes.Add(Ucode);
                    node.Tag = user;
                    //node.ForeColor = _editcolor;
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
                //this.WriteLog(exp.Message);
            }
        }
Esempio n. 3
0
        private void ShowUserDetails(TreeNode node)
        {
            try
            {
                Snackboxx.Core.User user         = (Snackboxx.Core.User)node.Tag;
                List <UserCode>     UserCodelist = new List <UserCode>();
                tbuserid.Text     = user.userid;
                tbusername.Text   = user.username;
                tbloginname.Text  = user.loginname;
                tbemail.Text      = user.EMail;
                tbpassword.Text   = user.Password;
                tb_userLimit.Text = user.betragsLimit;
                lbcodes.Items.Clear();

                string        restquery = "Select rest from T_User where UserID='" + user.userid + "'";
                SqlDataReader dr        = _dbconn.GetResult(restquery, null);
                while (dr.Read())
                {
                    user.rest = dr.GetValue(0).ToString();
                }

                dr.Close();

                //UserRights
                for (int i = 0; i < cBUserRights.Items.Count; ++i)
                {
                    if (((UserRight)cBUserRights.Items[i]).userRightID == user.UserRightID)
                    {
                        cBUserRights.SelectedIndex = i;
                    }
                }

                decimal rest = Convert.ToDecimal(user.rest);
                if (rest > 0)
                {
                    btndeleteselcode.Enabled = false;
                }
                else
                {
                    btndeleteselcode.Enabled = true;
                }


                string query = "Select * from T_UserCodes where UserID='" + user.userid + "'";
                List <Dictionary <string, string> > UserCodes = _dbconn.GetResultList(query, null);
                for (int i = 0; i < UserCodes.Count; ++i)
                {
                    Dictionary <string, string> UserCode = UserCodes[i];
                    UserCode Ucode = new UserCode();
                    Ucode.UserID = user.userid;
                    foreach (string key in UserCode.Keys)
                    {
                        if (key.Equals("CodeID"))
                        {
                            Ucode.CodeID = UserCode[key];
                        }

                        if (key.Equals("UserCode"))
                        {
                            Ucode.userCode = UserCode[key];
                        }

                        if (key.Equals("Preis"))
                        {
                            Ucode.Preis = UserCode[key].Replace(",", ".");
                        }

                        if (key.Equals("IsSnackCode"))
                        {
                            Ucode.Issnackcode = Convert.ToBoolean(UserCode[key]);
                        }
                    }

                    lbcodes.Items.Add(Ucode);
                    UserCodelist.Add(Ucode);
                }

                user.usercodes = UserCodelist;
                node.Tag       = user;


                string sumquery = "Select * from T_Posten where UserID='" + user.userid + "'";
                List <Dictionary <string, string> > allposten = _dbconn.GetResultList(sumquery, null);
                labAllPosten.Text = allposten.Count.ToString();


                decimal openSum  = 0;
                decimal closeSum = 0;
                decimal allSum   = 0;
                for (int i = 0; i < allposten.Count; ++i)
                {
                    Dictionary <string, string> posten = allposten[i];
                    decimal preis = Convert.ToDecimal(posten["Preis"]);
                    allSum += preis;
                }

                closeSum = allSum - rest;
                openSum  = rest;

                laballSum.Text   = allSum.ToString().Replace(",", ".");
                labCloseSum.Text = closeSum.ToString().Replace(",", ".");
                labopenSum.Text  = openSum.ToString().Replace(",", ".");
            }
            catch (Exception exp)
            {
                //this.WriteLog(exp.Message);
            }
        }
Esempio n. 4
0
 private void btndelallPos_Click(object sender, EventArgs e)
 {
     Snackboxx.Core.User user = (Snackboxx.Core.User)tvuser.SelectedNode.Tag;
 }
Esempio n. 5
0
        private void toolStripMenuItemSave_Click(object sender, EventArgs e)
        {
            try
            {
                _saveButtonWasClicked = true;
                Snackboxx.Core.User user = new Snackboxx.Core.User();
                user.userid    = tbuserid.Text;
                user.username  = this.InsertParameterCheck(tbusername.Text);
                user.loginname = this.InsertParameterCheck(tbloginname.Text);
                if (tb_userLimit.Text == "0.00" || tb_userLimit.Text == "")
                {
                    user.betragsLimit     = SnackboxxForm.DEFAULT_LIMIT;
                    user.nextBetragsLimit = SnackboxxForm.DEFAULT_LIMIT;
                }
                else
                {
                    user.betragsLimit     = tb_userLimit.Text;
                    user.nextBetragsLimit = tb_userLimit.Text;
                }

                string password = null;
                if (!string.IsNullOrEmpty(tbpassword.Text))
                {
                    password = _crypt.EncryptMessage(this.InsertParameterCheck(tbpassword.Text), _cryptstr);
                }
                user.Password = tbpassword.Text;
                user.EMail    = this.InsertParameterCheck(tbemail.Text);
                if (cBUserRights.Items.Count > 0)
                {
                    user.UserRightID = ((UserRight)cBUserRights.SelectedItem).userRightID;
                }

                ParameterObj timeObj = new ParameterObj();
                timeObj.name  = "@Timer";
                timeObj.type  = SqlDbType.DateTime;
                timeObj.value = DateTime.Now;

                if (string.IsNullOrEmpty(tbuserid.Text)) //newUser
                {
                    #region newUser

                    if (!_dbconn.DataSetExists("Select * from T_User where UserName='******'", null))
                    {
                        string insert = "Insert into T_User(UserName,Password,EMail,UserRightID,LoginName,BetragsLimit,NextBetragsLimit)"
                                        + "values('" + user.username + "','" + password + "','" + user.EMail + "','" + user.UserRightID + "','" +
                                        user.loginname + "','" + user.betragsLimit + "','" + user.nextBetragsLimit + "')";
                        _dbconn.Execute(insert, null);
                        string        query = "Select UserID from T_User where UserName='******'";
                        SqlDataReader dr    = _dbconn.GetResult(query, null);
                        while (dr.Read())
                        {
                            user.userid = dr.GetValue(0).ToString();
                        }

                        dr.Close();
                        user.usercodes = new List <UserCode>();
                        for (int i = 0; i < lbcodes.Items.Count; ++i)
                        {
                            UserCode Ucode = (UserCode)lbcodes.Items[i];
                            user.usercodes.Add(Ucode);
                            string insertcode = "Insert into T_UserCodes(UserID,UserCode,Preis,IsSnackCode)"
                                                + "values('" + user.userid + "','" + Ucode.userCode + "','" + Ucode.Preis + "','" + Ucode.Issnackcode + "')";
                            _dbconn.Execute(insertcode, null);
                        }

                        List <ParameterObj> paramlist = new List <ParameterObj>();
                        paramlist.Add(timeObj);

                        string insertK = "Insert into T_UserTimeKonto(UserID,InHouse,UpdateTime)values('" + user.userid + "','false',@Timer)";
                        _dbconn.Execute(insertK, paramlist);

                        TreeNode node = new TreeNode();
                        node.Text = user.username;
                        node.Tag  = user;
                        tvuser.Nodes.Add(node);
                        _form.SettssinfoONE("User Add... User " + user.username + " with follow ID " + user.userid + " is inserted...");
                        //this.WriteLog("User Add... User " + username + " with follow ID " + user.userid + " is inserted...");
                    }
                    else
                    {
                        _form.SettssinfoONE("User exists in the Database... " + user.username);
                        //this.WriteLog("User exists in the Database... " + username);
                    }

                    //this.btnclear_Click(sender, e);

                    #endregion
                }
                else //olduser
                {
                    #region olduser

                    string queryupd = "Update T_User set UserName='******',Password='******',LoginName='" + user.loginname
                                      + "',EMail='" + user.EMail
                                      + "',UserRightID='" + user.UserRightID
                                      + "',BetragsLimit ='" + user.betragsLimit
                                      + "' where UserID='" + user.userid + "'";

                    _dbconn.Execute(queryupd, null);


                    string query = "Select * from T_UserCodes where UserID='" + user.userid + "'";
                    List <Dictionary <string, string> > oldCodes = _dbconn.GetResultList(query, null);

                    string kquery = "Select * from T_UserTimeKonto where UserID='" + user.userid + "'";
                    if (!_dbconn.DataSetExists(kquery, null))
                    {
                        List <ParameterObj> paramlist = new List <ParameterObj>();
                        paramlist.Add(timeObj);

                        string insertK = "Insert into T_UserTimeKonto(UserID,InHouse,UpdateTime)values('" + user.userid + "','false',@Timer)";
                        _dbconn.Execute(insertK, paramlist);
                    }

                    for (int i = 0; i < oldCodes.Count; ++i)
                    {
                        bool   exists = false;
                        string codeid = oldCodes[i]["CodeID"];
                        for (int j = 0; j < lbcodes.Items.Count; ++j)
                        {
                            UserCode code = (UserCode)lbcodes.Items[j];
                            if (codeid == code.CodeID)
                            {
                                exists = true;
                            }
                        }

                        if (!exists)
                        {
                            string check = "Select * from T_User where UserID='" + user.userid + "' and rest>=0";
                            if (!_dbconn.DataSetExists(check, null))
                            {
                                string delquery = "Delete from t_UserCodes where UserID='" + user.userid + "' and CodeID='" + codeid + "'";
                                _dbconn.Execute(delquery, null);
                            }
                        }
                    }

                    List <UserCode> UserCodelist = new List <UserCode>();
                    for (int i = 0; i < lbcodes.Items.Count; ++i)
                    {
                        UserCode code = (UserCode)lbcodes.Items[i];
                        if (string.IsNullOrEmpty(code.CodeID))
                        {
                            code.UserID = tbuserid.Text;
                            string insert = "Insert into T_UserCodes(UserID,UserCode,Preis,IsSnackCode)"
                                            + "values('" + code.UserID + "','" + code.userCode + "','" + code.Preis + "','" + code.Issnackcode + "')";
                            //this.WriteInfo(insert);
                            _dbconn.Execute(insert, null);
                        }
                    }

                    _form.SettssinfoONE("User Edit: User " + tbusername.Text + " was edit...");

                    //this.WriteLog("User Edit: User " + tbusername.Text + " was edit...");
                    tvuser.SelectedNode.ForeColor = Color.Black;
                    tvuser.SelectedNode.Tag       = user;

                    #endregion
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message + "\n" + exp.StackTrace);
                //this.WriteLog("UserSave ... Exception: " + exp.Message);
            }
        }