예제 #1
0
        void InMain()
        {
            if (this.cmbwarehouse.Text == "")
            {
                return;
            }
            Comm.warehousecode = this.cmbwarehouse.SelectedValue.ToString();
            Comm.warehousename = this.cmbwarehouse.Text;
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                string x = HttpHelper.HttpPost("getBaseInfo", @"lcCode=" + Comm.lcCode);
                msg = (Model.Mmsg)JsonConvert.DeserializeObject(x, typeof(Model.Mmsg));
                if (msg == null)
                {
                    throw new Exception("错误信息捕捉失败");
                }
                if (!msg.success)
                {
                    throw new Exception(msg.msg);
                }
                Comm.basein = (Model.MbaseIn)JsonConvert.DeserializeObject(x, typeof(Model.MbaseIn));
                if (Comm.basein == null)
                {
                    throw new Exception("数据信息捕捉失败");
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            frmMain frm = new frmMain();

            //frmMenuPic frm = new frmMenuPic();
            frm.ShowDialog();
            panel1.Visible        = false;
            this.txtpassword.Text = "";
            this.txtuser.Text     = "";
            this.txtuser.Focus();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("1");
            //MessageBox.Show(x);
            Model.Mlogin m = null;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //string x = HttpHelper.HttpGet("login", @"account=" + this.txtuser.Text.Trim() + @"&password="******"");
                string x = HttpHelper.HttpPost("login", @"account=" + this.txtuser.Text.Trim() + @"&password="******"&isScanned=" + isScanned);
                msg = (Model.Mmsg)JsonConvert.DeserializeObject(x, typeof(Model.Mmsg));
                if (msg == null)
                {
                    throw new Exception("错误信息捕捉失败");
                }
                if (!msg.success)
                {
                    throw new Exception(msg.msg);
                }
                m = (Model.Mlogin)JsonConvert.DeserializeObject(x, typeof(Model.Mlogin));
                if (m == null)
                {
                    throw new Exception("数据信息捕捉失败");
                }
                Comm.userame                    = m.data.name;
                Comm.lcCode                     = m.data.lcCode;
                Comm.usercode                   = m.data.code;
                Comm.warehouseList              = m.data.warehourseList;
                this.cmbwarehouse.DataSource    = m.data.warehourseList;
                this.cmbwarehouse.DisplayMember = "name";
                this.cmbwarehouse.ValueMember   = "whId";

                this.panel1.Visible = true;
                this.cmbwarehouse.Focus();
                //this.txtuser.Enabled = false;
                //this.txtpassword.Enabled = false;
                //this.btnLogin.Enabled = false;
                Cursor.Current = Cursors.Default;
            }
            catch (WebException)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("网络错误");
                return;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message);
                this.txtuser.Focus();
                this.txtuser.SelectAll();
                return;
                //string _txt = @"d:\" + code + " Get " + DateTime.Now.ToString("yyMMddHHmmss") + ".txt";
                //using (StreamWriter sw = new StreamWriter(_txt))
                //{
                //    errMsg = errMsg = "单据下载成功,生成文件失败,Json文件地址为 " + _txt + " 查看文件联系相关人员";
                //    sw.Write(_Json);

                //}
                //return -1;
            }
        }