Пример #1
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //我现在只能用这个定时器不断查询的方式来更新打印记录了,因为存在数据库延迟。
            /**
            try
            {
                arrlistSellectRow.Clear();//当然首先是清空了。

                string strData = "";//查询打印记录时用

                for (int i = 0; i < dataGridView1.ColumnCount; i++)
                {
                    clsKeyValue keyvalue = new clsKeyValue(dataGridView1.Columns[i].Name, dataGridView1.CurrentRow.Cells[i].Value.ToString());
                    arrlistSellectRow.Add(keyvalue);

                    strData = strData + dataGridView1.CurrentRow.Cells[i].Value.ToString();//就是所有项连接起来

                }

                //导入打印记录,判断是根据表名和数据,
                ClsDataBase myClsDataBase = new ClsDataBase();
                dataGridViewPrintedRecords.DataSource = myClsDataBase.commandSelectPrintedRecord(strCurrentTableName, arrlistSellectRow);

            }
            catch (Exception ex)
            {

                Console.Error.WriteLine(ex.Message);
            }
             * */

            //用如下的这个,不用老是对arrlistSellectRow进行赋值操作
            try
            {
                if (arrlistSellectRow != null)
                {
                    string strData = "";
                    foreach (clsKeyValue item in arrlistSellectRow)
                    {
                        strData += item.Value;

                    }

                    //导入打印记录,判断是根据表名和数据,
                    ClsDataBase myClsDataBase = new ClsDataBase();
                    dataGridViewPrintedRecords.DataSource = myClsDataBase.commandSelectPrintedRecord(strCurrentTableName, arrlistSellectRow);
                }

            }
            catch (Exception exception)
            {
                ClsErrorFile.WriteLine(exception);

                //Console.Error.WriteLine(exception.Message);
            }
        }
Пример #2
0
        public void dataGridViewChangedCell()
        {
            //

            //因为存在点击列名而导致的异常,所以需要判断一下。
            if (dataGridView1.SelectedCells.Count > 0)
            {
                arrlistSellectRow.Clear();//当然首先是清空了。

                string strData = "";//查询打印记录时用

                for (int i = 0; i < dataGridView1.ColumnCount; i++)
                {
                    clsKeyValue keyvalue = new clsKeyValue(dataGridView1.Columns[i].Name, dataGridView1.CurrentRow.Cells[i].Value.ToString());
                    arrlistSellectRow.Add(keyvalue);

                    strData = strData + dataGridView1.CurrentRow.Cells[i].Value.ToString();//就是所有项连接起来

                }

                //导入打印记录,判断是根据表名和数据,
                ClsDataBase myClsDataBase = new ClsDataBase();
                dataGridViewPrintedRecords.DataSource = myClsDataBase.commandSelectPrintedRecord(strCurrentTableName, arrlistSellectRow);

                //更新图片
                XmlDocument xmlDoc = new XmlDocument();

                //如下得判断路径是否是绝对路径

                //值深度拷贝
                ArrayList arrlisttemp = new ArrayList();
                if (arrlistSellectRow != null)
                {
                    foreach (clsKeyValue item in arrlistSellectRow)
                    {
                        clsKeyValue clskeyvalue1 = new clsKeyValue(item.Key, item.Value);
                        arrlisttemp.Add(clskeyvalue1);
                    }
                }

                //还得判断是否有选择的条形码模板

                userControlCanvas1.setArrKeyValue(arrlisttemp);
                userControlCanvas1.Refresh();
                /**

                {

                    if (comboBoxBarcodeModel.SelectedItem != null)
                    {

                        string strPathName = ((clsKeyValue)comboBoxBarcodeModel.SelectedItem).Value;
                        //还得判断是否是相对路径,我的简单判断方法是是否有冒号":"
                        if (strPathName.IndexOf(":") < 0)
                        {
                            //还有得判断首字符是不是"\\",如果不是就加上
                            if (strPathName.Substring(0) == "\\")
                            {
                                strPathName = Application.StartupPath + strPathName;
                            }
                            else
                            {
                                strPathName = Application.StartupPath + "\\" + strPathName;
                            }
                        }

                        ClsBarcodePrint myBarcodePrint = new ClsBarcodePrint();

                        //如下是画布设置
                        userControlCanvas1.Loader(strPathName);

                        //根据纸张的大小选择放大率
                        calculateCanvas();

                        userControlCanvas1.setArrKeyValue(arrlisttemp);

                        userControlCanvas1.ZoomPaperToScreen();

                        userControlCanvas1.Refresh();

                        //picCanvas.Image = myBarcodePrint.xmlToBarcodeImage(clsBarcodePrint.populateVariable(xmlDoc, frmMain.arrlistSellectRow));
                    }
                }
                 * */

                //得更新要打印数量
                //加载变量名。从arrlistSellectRow得到列名。
                comboBoxVaribaleName_SelectedIndexChanged(this, new EventArgs());

            }
        }