Пример #1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                string id = txt_userid.Text.Trim();
                if (id == string.Empty || id == null)
                {
                    MessageBox.Show("ERROR", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txt_userid.Focus();
                    return;
                }
                else
                {
                    OfflineForm frm1 = new OfflineForm();
                    this.Hide();
                    frm1.String1 = id;
                    frm1.SetValue();
                    frm1.Show();
                }
            }
            else
            {
                if (txt_userid.Text.Trim() == string.Empty || txt_userid.Text.Trim() == null)
                {
                    MessageBox.Show("ERROR", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txt_userid.Focus();
                    return;
                }

                workingForm1 frm = new workingForm1();
                frm.StartPosition = FormStartPosition.CenterScreen;
                frm.Show();
                frm.BringToFront();

                string opacurl = libhp.ini_opacurl();
                string id      = txt_userid.Text.Trim();
                string pwd     = txt_pwd.Text.Trim();
                string url     = string.Format("http://{0}/getservice.ashx?mode=1&userid={1}&pwd={2}", opacurl, id, pwd);

                try
                {
                    string get = string.Empty;

                    if (libhp.ini_mode() == "0")
                    {
                        get = libhp.getservice(url);
                    }
                    else
                    {
                        get = sqlhp.admin_login(id, pwd);
                    }


                    Checkadmi m = JsonConvert.DeserializeObject <Checkadmi>(get);

                    switch (m.result.ToString())
                    {
                    case "0":
                    {
                        frm.Close();

                        Form1 frm1 = new Form1();
                        this.Hide();
                        frm1.String1 = m.userid;
                        frm1.String2 = m.location;
                        frm1.String3 = id;
                        frm1.SetValue();
                        frm1.Show();

                        break;
                    }

                    default:
                    {
                        Thread.Sleep(1000);
                        frm.Close();
                        MessageBox.Show(m.msg.ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        libhp.clean_control(txt_userid, txt_pwd);
                        txt_userid.Focus();
                        break;
                    }
                    }
                }
                catch
                {
                    Thread.Sleep(10000);
                    MessageBox.Show("ERROR", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Application.Exit();
                }
            }
        }
Пример #2
0
        private void btn_readerid_Click(object sender, EventArgs e)  //
        {
            workingForm1 frm = new workingForm1();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Show();
            frm.Activate();

            string opacurl  = libhp.ini_opacurl();
            string readerid = txt_readerid.Text;
            string url      = string.Format("http://{0}/getservice.ashx?mode=2&readerid={1}", opacurl, readerid);

            string get = string.Empty;

            if (libhp.ini_mode() == "0")
            {
                get = libhp.getservice(url);
            }
            else
            {
                get = sqlhp.reader_login(readerid);
            }



            Login m = JsonConvert.DeserializeObject <Login>(get);

            txt_readerid.Text = m.reader01;
            lbl_reader02.Text = m.reader02;
            lbl_reader72.Text = m.reader72;
            lbl_yxrq.Text     = m.yxrq;
            lbl_yyrgnum.Text  = m.yyrgnum.ToString();
            lbl_fk.Text       = m.fk.ToString();
            lbl_tsk.Text      = m.tsk.ToString();
            lbl_tsy.Text      = m.tsy.ToString();
            lbl_fsk.Text      = m.fsk.ToString();
            lbl_fsy.Text      = m.fsy.ToString();
            lbl_qkk.Text      = m.qkk.ToString();
            lbl_qky.Text      = m.qky.ToString();



            switch (m.result.ToString())
            {
            case "0":
            {
                frm.Close();
                string url2 = string.Format("http://{0}/getservice.ashx?mode=5&readerid={1}", opacurl, readerid);

                string get2 = string.Empty;

                if (libhp.ini_mode() == "0")
                {
                    get2 = libhp.getservice(url2);
                }
                else
                {
                    get2 = sqlhp.book_hist(readerid);
                }

                DataTable dt = JsonConvert.DeserializeObject <DataTable>(get2);
                dataGridView_hist.DataSource = dt;
                if (dt.Rows.Count <= 0)
                {
                    //MessageBox.Show("not found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txt_barcode.Enabled = true;
                    txt_barcode.Focus();
                    return;
                }
                libhp.datagv_field_width(dataGridView_hist);
                libhp.datagv_clean(dataGridView_lt);
                libhp.clean_control(txt_barcode);
                txt_barcode.Enabled = true;
                txt_barcode.Focus();


                DataGridViewImageColumn dgvImage = new DataGridViewImageColumn();
                dgvImage.HeaderText = "";

                DataGridViewTextBoxColumn dgvBarcode = new DataGridViewTextBoxColumn();
                dgvBarcode.HeaderText = "";

                DataGridViewTextBoxColumn dgvId = new DataGridViewTextBoxColumn();
                dgvId.HeaderText = "";

                DataGridViewTextBoxColumn dgvTitle = new DataGridViewTextBoxColumn();
                dgvTitle.HeaderText = "";

                DataGridViewTextBoxColumn dgvCheckOut = new DataGridViewTextBoxColumn();
                dgvCheckOut.HeaderText = "";

                DataGridViewTextBoxColumn dgvReturn = new DataGridViewTextBoxColumn();
                dgvReturn.HeaderText = "";
                dgvReturn.DefaultCellStyle.ForeColor = Color.Red;

                DataGridViewTextBoxColumn dgvResult = new DataGridViewTextBoxColumn();
                dgvResult.HeaderText = "";

                dataGridView_lt.Columns.Add(dgvImage);
                dataGridView_lt.Columns.Add(dgvId);
                dataGridView_lt.Columns.Add(dgvBarcode);
                dataGridView_lt.Columns.Add(dgvTitle);
                dataGridView_lt.Columns.Add(dgvCheckOut);
                dataGridView_lt.Columns.Add(dgvReturn);
                dataGridView_lt.Columns.Add(dgvResult);

                dataGridView_lt.Columns[0].Width = 30;
                dataGridView_lt.Columns[1].Width = 50;
                dataGridView_lt.Columns[2].Width = 90;
                dataGridView_lt.Columns[3].Width = 250;
                dataGridView_lt.Columns[4].Width = 150;
                dataGridView_lt.Columns[5].Width = 150;
                dataGridView_lt.Columns[6].Width = 280;

                dataGridView_lt.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView_lt.AllowUserToAddRows  = false;



                break;
            }

            default:
            {
                frm.Close();
                libhp.clean_control(txt_barcode, txt_readerid, lbl_reader02, lbl_reader72, lbl_yxrq, lbl_yyrgnum, lbl_fk);
                libhp.datagv_clean(dataGridView_hist, dataGridView_lt);
                MessageBox.Show(m.msg.ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txt_barcode.Enabled = false;

                break;
            }
            }
        }