示例#1
0
文件: clsMain.cs 项目: radtek/InfoPos
        public Result Login(int userno, string pwd, string pcname, string ip, string mac, bool relogin)
        {
            try
            {
                Result res = new Result();
                moConnection.CheckInterval = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "CheckInterval", "10"));
                moConnection.WaitTimeout   = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "WaitTimeout", "60"));
                moConnection.Disconnect();
                moConnection.Connect(mstrServerIP, mintServerPort);
                if (relogin == false)
                {
                    ip  = moConnection.IpLocal;
                    mac = moConnection.NetworkAddress;
                }

                if (moConnection.Connected)
                {
                    object[] param = new object[] { userno, pwd, pcname, ip, mac, relogin };
                    res = moConnection.Call(userno, 101, 110000, 110000, param);

                    if (res.ResultNo == 0)
                    {
                        moUser.UserNo     = userno;
                        moUser.BranchCode = Static.ToStr(res.Param[0]);
                        moUser.UserFName  = Static.ToStr(res.Param[1]);
                        moUser.UserFName2 = Static.ToStr(res.Param[2]);
                        moUser.UserLevel  = Static.ToInt(res.Param[3]);
                        moUser.UserLName  = Static.ToStr(res.Param[4]);
                        moUser.UserLName2 = Static.ToStr(res.Param[5]);

                        moUser.Level1 = Static.ToInt(res.Param[6]);
                        moUser.Level2 = Static.ToInt(res.Param[7]);
                        moUser.Level3 = Static.ToInt(res.Param[8]);
                        moUser.Level4 = Static.ToInt(res.Param[9]);

                        moUser.TxnGroupLevel = Static.ToInt(res.Param[10]);

                        mstrDS = res.Data;
                    }
                    return(res);
                }
                else
                {
                    // Серверт холбогдож чадсангүй
                    return(new Result(7, "Серверт холбогдож чадсангүй!"));
                }
            }
            catch (Exception ex)
            {
                return(new Result(7, ex.Message));
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateFields() == true)
            {
                #region [ Нууц үг солих]
                string   OldPass;
                string   NewPass;
                object[] M = new object[5];

                Result res = new Result();


                OldPass = Static.Encrypt(txtOldPass.Text);
                NewPass = Static.Encrypt(txtNewPass.Text);
                M[0]    = moUser.UserNo;
                M[1]    = OldPass;
                M[2]    = NewPass;
                M[3]    = txtNewPass.Text.Length;
                M[4]    = Count;
                try
                {
                    res = moConnection.Call(moUser.UserNo, 101, 110002, 110002, M);

                    if (res.ResultNo == 0)
                    {
                        moUser.UserPassword = NewPass;

                        MessageBox.Show("Нууц үгийг амжилттай солилоо",
                                        "", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show(res.ResultDesc, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.DialogResult = DialogResult.Cancel;
                }

                #endregion
            }
        }
示例#3
0
        internal int LoadTableData(int reportpriv, ref DataSet ds, ref string error)
        {
            int success = 0;

            if (client != null)
            {
                if (ds == null)
                {
                    ds = new DataSet();
                }
                for (int i = 0; i < tables.Count; i++)
                {
                    string tablename = string.Format("Table{0}", i + 1);
                    string sql       = (string)tables[tablename];

                    if (!string.IsNullOrEmpty(sql))
                    {
                        #region Collect parameters
                        List <string> paramnames  = new List <string>();
                        ArrayList     paramvalues = new ArrayList();

                        foreach (ParameterItem p in parameters)
                        {
                            if (p == null || p.TableNumbers == null || p.TableNumbers.Length <= 0 ||
                                Array.IndexOf <int>(p.TableNumbers, 0) >= 0 ||
                                Array.IndexOf <int>(p.TableNumbers, i) >= 0)
                            {
                                //      string regexPattern = @"(?<=TO_CHAR(BRANCHNO) =)[^;\n]*";
                                string regexPattern = @":ppBranchCode";
                                string regexUserno  = @":ppUserNo";
                                string regexLevel1  = @":pLevelNo1";
                                string regexLevel2  = @":pLevelNo2";
                                string regexLevel3  = @":pLevelNo3";
                                string regexLevel4  = @":pLevelNo4";
                                string regexLevel5  = @":pTxnDate";
                                var    pBranchCode  = Regex.Match(sql, regexPattern); //
                                var    pUserNo      = Regex.Match(sql, regexUserno);  //
                                var    LevelNo1     = Regex.Match(sql, regexLevel1);  //
                                var    LevelNo2     = Regex.Match(sql, regexLevel2);  //
                                var    LevelNo3     = Regex.Match(sql, regexLevel3);  //
                                var    LevelNo4     = Regex.Match(sql, regexLevel4);  //
                                var    Txndate      = Regex.Match(sql, regexLevel5);  //
                                if (Static.ToStr(pBranchCode) != "")
                                {
                                    paramnames.Add("ppBranchCode");
                                    paramvalues.Add(_core.RemoteObject.User.BranchCode);
                                }
                                if (Static.ToStr(pUserNo) != "")
                                {
                                    paramnames.Add("ppUserNo");
                                    paramvalues.Add(_core.RemoteObject.User.UserNo);
                                }
                                if (Static.ToStr(LevelNo1) != "")
                                {
                                    paramnames.Add("pLevelNo1");
                                    paramvalues.Add(_core.RemoteObject.User.Level1);
                                }
                                if (Static.ToStr(LevelNo2) != "")
                                {
                                    paramnames.Add("pLevelNo2");
                                    paramvalues.Add(_core.RemoteObject.User.Level2);
                                }
                                if (Static.ToStr(LevelNo3) != "")
                                {
                                    paramnames.Add("pLevelNo3");
                                    paramvalues.Add(_core.RemoteObject.User.Level3);
                                }
                                if (Static.ToStr(LevelNo4) != "")
                                {
                                    paramnames.Add("pLevelNo4");
                                    paramvalues.Add(_core.RemoteObject.User.Level4);
                                }

                                if (Static.ToStr(Txndate) != "")
                                {
                                    paramnames.Add("pTxnDate");
                                    paramvalues.Add(_core.TxnDate);
                                }


                                paramvalues.Add(p.Value);
                                paramnames.Add(p.Id);
                            }
                        }

                        #endregion
                        #region Calling server function
                        object[] param = new object[] { sql, paramnames.ToArray(), paramvalues.ToArray() };
                        Result   r     = client.Call(userno, 107, 107001, reportpriv, param);
                        //  Result rr = client.Call(userno, 107, 107001, reportpriv, param);
                        if (r.ResultNo != 0)
                        {
                            success = r.ResultNo;
                            error   = r.ResultDesc;
                            break;
                        }

                        r.Data.Tables[0].TableName = tablename;
                        ds.Tables.Add(r.Data.Tables[0].Copy());
                        r.Data = ds;
                        //   string tablename = string.Format("Table{0}", i + 1);
                        // string sql = (string)tables[tablename];


                        //      ds.Tables.Add(r.Data.Tables[1].Copy());

                        #endregion
                    }
                }
            }
            if (success != 0)
            {
                ds.Dispose();
            }
            return(success);
        }