Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            List <string> list      = new List <string>();
            bool          _isTooBig = false;

            foreach (DataGridViewRow dvgr in dataGridView1.Rows)
            {
                if (dvgr.Cells["cSel"].Value != null && (bool)dvgr.Cells["cSel"].Value)
                {
                    list.Add(dvgr.Cells["cBarcode"].Value.ToString());
                    int _cnt = int.Parse(dvgr.Cells["cPrintCnt"].Value.ToString());
                    if (_cnt > 0)
                    {
                        _isTooBig = true;
                    }
                }
            }

            if (list.Count <= 0)
            {
                MessageBox.Show("请勾选要打印的条码!");
                return;
            }

            //如果超过1次,不是管理员就报错
            if (_isTooBig && !Global.IsAdmin)
            {
                MessageBox.Show("勾选的条码已超过打印次数,请联系管理员!");
                return;
            }

            InWDetail iw = new InWDetail();

            try
            {
                foreach (string s in list)
                {
                    // 因 TSC 打印机设置无效(会多次弹出有关警告),所以暂时注释掉下行代码
                    //BarcodeService.TSC(s);  // 项目 Common 的 BarcodeService 类
                    iw.UpdatePrintCnt(s);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印失败!原因:" + ex.Message);
                MyLog.WriteLog(ex.Message);
            }
            MessageBox.Show("打印结束!");

            LoadService();
            cbx_All_CheckedChanged(null, null);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            List<string> list = new List<string>();
            bool _isTooBig = false;
            foreach (DataGridViewRow dvgr in dataGridView1.Rows)
            {
                if (dvgr.Cells["cSel"].Value!=null && (bool)dvgr.Cells["cSel"].Value)
                {
                    list.Add(dvgr.Cells["cBarcode"].Value.ToString());
                    int _cnt = int.Parse(dvgr.Cells["cPrintCnt"].Value.ToString());
                    if (_cnt > 0)
                    {
                        _isTooBig = true;
                    }
                }
            }

            if (list.Count <= 0)
            {
                MessageBox.Show("请勾选要打印的条码!");
                return;
            }

            //如果超过1次,不是管理员就报错
            if (_isTooBig && !Global.IsAdmin)
            {

                MessageBox.Show("勾选的条码已超过打印次数,请联系管理员!");
                return;

            }

            InWDetail iw = new InWDetail();
            try
            {
                foreach (string s in list)
                {
                    BarcodeService.TSC(s);
                    iw.UpdatePrintCnt(s);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印失败!原因:" + ex.Message);
                MyLog.WriteLog(ex.Message);
            }
            MessageBox.Show("打印结束!");
            LoadService();
            cbx_All_CheckedChanged(null, null);
        }