public FrmLoadExcelRecords()
        {
            InitializeComponent();

            //将main表填充到窗体中。
            ClsDataBase myClsDataBase=new ClsDataBase ();
            dataGridView1.DataSource = myClsDataBase.getMainTable();

            strTableName = "";//初始化而已
        }
示例#2
0
        public string strCurrentTableName; //

        #endregion Fields

        #region Constructors

        public ClsImportExcel()
        {
            //初始化
            loadExcelDataTalbe = new DataTable();
            strCurrentTableName = "";

            //选择是哪个档口
            FrmSCAndShop myFrmSCAndShop = new FrmSCAndShop();

            if (myFrmSCAndShop.ShowDialog() != DialogResult.OK)//只要判断这个就可以了。
            {
                MessageBox.Show("请输入单号(名)和档口号(名),以方便以后查看");
                return;

            }

            //选择文件
            string strFile;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "Excel97-2003 Excel 2007(*.xls *.xlsx)|*.xls;*.xlsx|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strFile = openFileDialog1.FileName;
            }
            else
            {
                MessageBox.Show("请选择文件");
                return;
            }

            // 首先判断这个excel表格有几页,如果只有一页就直接导入,如果不止一页就让用户选择
            string[] strSheetNames = GetExcelSheetNames(strFile);

            if (strSheetNames.Length == 1)
            {
                //读入表
                loadExcelDataTalbe = GetExcelToDataSet(strFile, false, strSheetNames[0]);

            }
            else
            {
                //选择读入那个表
                FrmChooseExcelSheet frm = new FrmChooseExcelSheet(strSheetNames);
                frm.ShowDialog();
                loadExcelDataTalbe = GetExcelToDataSet(strFile, false, FrmChooseExcelSheet.strSheetName);

            }

            //将导入的表导入到数据库,
            ClsDataBase myClsDataBase = new ClsDataBase();
            strCurrentTableName = myClsDataBase.loadExcel(FrmSCAndShop.strSC, FrmSCAndShop.strShop, Path.GetFileName(strFile), loadExcelDataTalbe);
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            ClsDataBase myClsDataBase = new ClsDataBase();
            if (txtStrSC.Text=="")
            {
                MessageBox.Show("您没有输入订单号");
                //将main表填充到窗体中。

                dataGridView1.DataSource = myClsDataBase.getMainTable();
                strTableName = "";//初始化而已
                return;
            }
            //将main表填充到窗体中。

            dataGridView1.DataSource = myClsDataBase.commandSelect("select * from main where [单号]=\"" + txtStrSC.Text+"\";");
        }
        /// <summary>
        /// 这个方法是充满打印
        /// </summary>
        /// <param name="printDetails"></param>
        private void PrintBarcode2(queuePrintItem printDetails)
        {
            //深度拷贝,因为在打印事件中需要调用这个方法
            currentQueueItem = ClsXmlSerialization.DeepCopy<queuePrintItem>(printDetails);

            Shapes myShapes;
            //首先也是取得纸张的行数和列数
            try
            {
                myShapes = ClsXmlSerialization.Load<Shapes>(currentQueueItem.ShapesFileName);
            }
            catch (System.Exception ex)
            {
                return;//如果不能取得,那么就直接返回

            }

            int intNumOfLine = myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfLine;
            int intNumOfColumn = myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfColumn;

            while ((currentQueueItem.IntCount > 0))
            {
                //如下的才能打印
                if (!isprintDocument_PrintPage)
                {
                    //如下的就是具体构造每一个printDocument了
                    myPrintDocument = new PrintDocument();
                    myPrintDocument.DefaultPageSettings.Landscape = myShapes.BarcodePageSettings.BarcodePaperLayout.LandScape;//设置是否横向
                    int intP = ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages;
                    //设置多少张纸,这个打印份数只是一个数据的,因为如果第一个没有充满纸张,那么就没必要多份了。
                    intPrintPage = (int)(intP / (intNumOfLine * intNumOfColumn));
                    if (intPrintPage == 0)//有时候会出现不足一张的情况
                        intPrintPage = 1;

                    //根据纸张的连续等问题
                    //设置打印机
                    if (strPrinterName != "")
                    {
                        myPrintDocument.PrinterSettings.PrinterName = strPrinterName;
                    }

                    myPrintDocument.PrintController = new StandardPrintController();//这个据说可以不显示那个打印进度对框框
                    myPrintDocument.DocumentName = "打印条形码";//设置完后可在打印对话框及队列中显示(默认显示document)
                    //打印输出(过程)
                    myPrintDocument.PrintPage += new PrintPageEventHandler(myPrintDocument_PrintPage);

                    myPrintDocument.OriginAtMargins = false;//从位于可打印区域的左上角打印
                    //必须得设置自定义纸张,要不然会存在顶点问题,比如说有些条形啊打印机的打印宽度为4英寸,而实际纸张宽度不是4英寸,就会存在打印时候顶点是打印机的顶点,而不是实际纸张的顶点。
                    myPrintDocument.DefaultPageSettings.PaperSize = myShapes.BarcodePageSettings.BarcodePaperLayout.BarcodePaperSize;//设置纸张
                    //如下是设置边距
                    /**如下的经测试会产生不可预测的偏移
                    myPrintDocument.DefaultPageSettings.Margins.Top = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Top / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Bottom = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Bottom / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Left = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Left / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Right = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Right / 0.254);

                     * */
                    //每次打印
                    myPrintDocument.PrinterSettings.Copies = (short)intPrintPage;//首先就是一次性全部打印完毕,设置份数就是页数.
                    if (myPrintDocument.PrinterSettings.MaximumCopies < intPrintPage)//如果最高能打印的份数比要打印的页数少,就按照最高能打印的份数.
                        myPrintDocument.PrinterSettings.Copies = (short)myPrintDocument.PrinterSettings.MaximumCopies;

                    //如果能多份打印,就需要提前删掉那些,比如说要打印5个,每张纸可以打印2个,那么这里第一次的份数就是2,但是在打印进程中只会减少2个,会造成重复打印
                    ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages = ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages - (myPrintDocument.PrinterSettings.Copies - 1) * (intNumOfLine * intNumOfColumn);

                    try
                    {
                        isprintDocument_PrintPage = true;
                        myPrintDocument.Print();
                        //这里发出打印消息。
                        //isprintDocument_PrintPage = true;// 因为上一个打印进程也需要时间,所以这里先设置了。
                        myPrintDocument.Dispose();//释放

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("没有打印成功,原因:" + ex.Message);
                        isprintDocument_PrintPage = false;
                        return;
                    }

                }
            }

            //保存打印记录,这里用比较省事的方法
            ClsDataBase myClsDataBase = new ClsDataBase();
            foreach (queuePrintItemRowAndPages item in printDetails.arrlistqueuePrintItemRowAndPages)
            {
                myClsDataBase.commandAddPrintedRecord(printDetails.strTableName, item.arrlistRow, item.intPages);
                OnBarcodePrinted(new printedEventArgs());//发出打印消息

            }
        }
        //如下的方法也准备注释掉,因为不需要了。
        /**
        public  Bitmap xmlToBarcodeImage(XmlDocument xmlBarcodeModel)
        {
            //首先取得纸张的尺寸和DPI
            //再根据纸张尺寸画画布
            //在读取xml模板内容画图
            //最后返回画布就可以了

            //double dwPaparWidth = 40, fltPaperHeight = 40;//默认纸张大小
            //取得纸张尺寸如下

            XmlElement myXmlEleRoot = xmlBarcodeModel.DocumentElement;
            foreach (XmlNode myxmlNode in myXmlEleRoot.ChildNodes)
            {
                string strNodeName = myxmlNode.Name.ToLower();
                switch (strNodeName)
                {

                    case ("paper"):
                        XmlElement xmltemp = (XmlElement)myxmlNode;//用这个转换只是因为xmlNode没有GetAttribute
                       // fltPaperWidth = strAttributeValueToFloat(xmltemp,"PaperWidth");
                        //fltPaperHeight = strAttributeValueToFloat(xmltemp,"PaperHeight");

                        break;
                }
            }

            //建立画布部分

            int iW=(int)(fltPaperWidth*fltDPIX/25.4);
            int iH=(int)(fltPaperHeight*fltDPIY/25.4);
            Bitmap imageCanvas = new Bitmap(iW,iH);
            imageCanvas.SetResolution(fltDPIX, fltDPIY);

            Graphics g = Graphics.FromImage(imageCanvas);
            g.PageUnit = GraphicsUnit.Millimeter;

            //如下被认为可以清晰文字。
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;

            g.Clear(Color.White);

            //如下就是在这个画布上绘图了

            foreach (XmlNode myxmlNode in myXmlEleRoot.ChildNodes)
            {
                string strNodeName = myxmlNode.Name.ToLower();
                switch (strNodeName)
                {
                    case "shapes":

                        //如下是循环把形状的属性
                        #region

                        //如下是循环把形状的属性
                        foreach (XmlElement xmlElementShapes in myxmlNode.ChildNodes)
                        {
                            string strShapesName = xmlElementShapes.Name.ToLower();
                            FontStyle myFontStyle;
                            Font font1;
                            float   fX, fY  ,fWidth ,fHeight ;
                            SolidBrush drawBrush;
                            PointF poingStr;

                            switch (strShapesName)
                            {

                                case "statictext":
                                    //首先建立一个静态文本属性对性
                                    #region

                                    //字体风格,加粗倾斜下划线
                                    myFontStyle = new FontStyle();

                                    if (xmlElementShapes.GetAttribute("isBold").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Bold;

                                    }
                                    if (xmlElementShapes.GetAttribute("isItalic").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Italic;
                                    }
                                    if (xmlElementShapes.GetAttribute("isUnderLine").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Underline;
                                    }

                                     font1 = new Font(xmlElementShapes.GetAttribute("FontName"), Convert.ToSingle(xmlElementShapes.GetAttribute("FontSize")),myFontStyle);

                                    //这样字体就读取好了,接下来读取位置。
                                     fX = strAttributeValueToFloat(xmlElementShapes,"X");
                                     fY = strAttributeValueToFloat(xmlElementShapes,"Y") ;
                                     poingStr = new PointF(fX, fY);
                                     drawBrush = new SolidBrush(Color.Black);

                                    g.DrawString(xmlElementShapes.InnerText, font1, drawBrush, poingStr);
                                    drawBrush.Dispose();
                                    font1.Dispose();

                                    break;

                                    #endregion
                                //如下是设置变量文字
                                case "variabletext":
                                    #region
                                    //变量字体跟静态字体没有什么本质区别,唯一的区别是加了后缀

                                    //字体风格,加粗倾斜下划线
                                    myFontStyle = new FontStyle();

                                    if (xmlElementShapes.GetAttribute("isBold").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Bold;

                                    }
                                    if (xmlElementShapes.GetAttribute("isItalic").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Italic;
                                    }
                                    if (xmlElementShapes.GetAttribute("isUnderLine").ToLower() == "true")
                                    {
                                        myFontStyle = myFontStyle | FontStyle.Underline;
                                    }

                                     font1 = new Font(xmlElementShapes.GetAttribute("FontName"), Convert.ToSingle(xmlElementShapes.GetAttribute("FontSize")), myFontStyle);

                                    //这样字体就读取好了,接下来读取位置。
                                     fX = strAttributeValueToFloat(xmlElementShapes,"X");
                                     fY = strAttributeValueToFloat(xmlElementShapes,"Y");
                                     poingStr = new PointF(fX, fY);
                                     drawBrush = new SolidBrush(Color.Black);
                                     string strSuffix = xmlElementShapes.GetAttribute("suffix");

                                    g.DrawString(xmlElementShapes.InnerText+strSuffix, font1, drawBrush, poingStr);
                                    drawBrush.Dispose();

                                    break;
                                    #endregion

                                //如下是条形码
                                case "barcode":
                                    #region

                                    //条形码可能有异常,比如说位数不符等等
                                    try
                                    {

        ;
                                        string  strEncoding = xmlElementShapes.GetAttribute("Encoding");
                                        BarcodeLib.TYPE myType =BarcodeLib.TYPE.EAN13;
                                        switch (strEncoding)
                                        {
                                            case "EAN13":
                                                myType = BarcodeLib.TYPE.EAN13;
                                                break;
                                            case "EAN8":
                                                myType = BarcodeLib.TYPE.EAN8;
                                                break;
                                            case "FIM":
                                                myType = BarcodeLib.TYPE.FIM;
                                                break;
                                            case "Codabar":
                                                myType = BarcodeLib.TYPE.Codabar;
                                                break;
                                            case "UPCA":
                                                myType = BarcodeLib.TYPE.UPCA;
                                                break;
                                            case "UPCE":
                                                myType = BarcodeLib.TYPE.UPCE;
                                                break;
                                            case "UPC_SUPPLEMENTAL_2DIGIT":
                                                myType = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT;
                                                break;
                                            case "UPC_SUPPLEMENTAL_5DIGIT":
                                                myType = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT;
                                                break;
                                            case "CODE39":
                                                myType = BarcodeLib.TYPE.CODE39;
                                                break;
                                            case "CODE39Extended":
                                                myType = BarcodeLib.TYPE.CODE39Extended;
                                                break;
                                            case "CODE128":
                                                myType = BarcodeLib.TYPE.CODE128;
                                                break;
                                            case "CODE128A":
                                                myType = BarcodeLib.TYPE.CODE128A;
                                                break;
                                            case "CODE128B":
                                                myType = BarcodeLib.TYPE.CODE128B;
                                                break;
                                            case "CODE128C":
                                                myType = BarcodeLib.TYPE.CODE128C;
                                                break;
                                            case "ISBN":
                                                myType = BarcodeLib.TYPE.ISBN;
                                                break;
                                            case "Interleaved2of5":
                                                myType = BarcodeLib.TYPE.Interleaved2of5;
                                                break;
                                            case "Standard2of5":
                                                myType = BarcodeLib.TYPE.Standard2of5;
                                                break;
                                            case "Industrial2of5":
                                                myType = BarcodeLib.TYPE.Industrial2of5;
                                                break;
                                            case "PostNet":
                                                myType = BarcodeLib.TYPE.PostNet;
                                                break;
                                            case "BOOKLAND":
                                                myType = BarcodeLib.TYPE.BOOKLAND;
                                                break;
                                            case "JAN13":
                                                myType = BarcodeLib.TYPE.JAN13;
                                                break;
                                            case "MSI_Mod10":
                                                myType = BarcodeLib.TYPE.MSI_Mod10;
                                                break;
                                            case "MSI_2Mod10":
                                                myType = BarcodeLib.TYPE.MSI_2Mod10;
                                                break;
                                            case "MSI_Mod11":
                                                myType = BarcodeLib.TYPE.MSI_Mod11;
                                                break;
                                            case "MSI_Mod11_Mod10":
                                                myType = BarcodeLib.TYPE.MSI_Mod11_Mod10;
                                                break;
                                            case "Modified_Plessey":
                                                myType = BarcodeLib.TYPE.Modified_Plessey;
                                                break;
                                            case "CODE11":
                                                myType = BarcodeLib.TYPE.CODE11;
                                                break;
                                            case "USD8":
                                                myType = BarcodeLib.TYPE.USD8;
                                                break;
                                            case "UCC12":
                                                myType = BarcodeLib.TYPE.UCC12;
                                                break;
                                            case "UCC13":
                                                myType = BarcodeLib.TYPE.UCC13;
                                                break;
                                            case "LOGMARS":
                                                myType = BarcodeLib.TYPE.LOGMARS;
                                                break;
                                            case "ITF14":
                                                myType = BarcodeLib.TYPE.ITF14;
                                                break;
                                            case "TELEPEN":
                                                myType = BarcodeLib.TYPE.TELEPEN;
                                                break;

                                        }

                                        BarcodeLib.Barcode bar = new BarcodeLib.Barcode();
                                        fX = strAttributeValueToFloat(xmlElementShapes,"X");
                                        fY = strAttributeValueToFloat(xmlElementShapes,"Y") ;
                                        poingStr = new PointF(fX, fY);
                                        fWidth = strAttributeValueToFloat(xmlElementShapes,"Width") ;
                                        fHeight = strAttributeValueToFloat(xmlElementShapes,"Height");
                                        bar.IncludeLabel = false; ;
                                        if (xmlElementShapes.GetAttribute("isIncludeLabel").ToLower() == "true")
                                        {
                                             bar.IncludeLabel = true;
                                        }

                                        int intBarCodeWidth = (int)(fWidth * g.DpiX / 25.4);
                                        int intBarCodeHeight = (int)(fHeight * g.DpiY / 25.4);

                                        Image myImage = bar.Encode(myType, xmlElementShapes.InnerText, intBarCodeWidth, intBarCodeHeight,g.DpiX,g.DpiY);
                                        g.DrawImage(myImage, poingStr);
                                        bar.Dispose();

                                    }
                                    catch (Exception e)
                                    {
                                        MessageBox.Show(e.Message);
                                    }

                                    #endregion
                                    break;
                                //如下设置其他形状

                            }
                        }
                        break;

                        #endregion

                }
            }

            //如下是如果没有注册,在左上角写上文字" BarcodeTerminator"
            if (!isZhuCe)
            {
                g.DrawString(" BarcodeTerminator", new Font("Arial", 6), new SolidBrush(Color.Black), new Point(0, 0));

            }

            return imageCanvas;

        }
         * */
        /**

        //变量替换,测试成功
        public static XmlDocument populateVariable(XmlDocument xmlDoc)
        {
            //用xpath搜索的方法来替换。
            XmlDocument myxml = xmlDoc;//赋值而已
            foreach (clsKeyValue keyvalue in frmMain.arrlistSellectRow)
            {
                XmlNodeList nodeList1 = myxml.SelectNodes("//VariableText[@variableName='" + keyvalue.Key + "']");

                foreach (XmlNode myXmlNode in nodeList1)
                {
                    myXmlNode.InnerText = keyvalue.Value;
                }
                XmlNodeList nodeList2 = myxml.SelectNodes("//Barcode[@variableName='" + keyvalue.Key + "']");

                foreach (XmlNode myXmlNode in nodeList2)
                {
                    myXmlNode.InnerText = keyvalue.Value;
                }
            }

            return myxml;

        }
         *
         * */
        private void PrintBarcode(queuePrintItem printDetails)
        {
            //首先判断是否是充满
            if (printDetails.IsFull)
            {
                //如下就是充满
                //项的情况,所以要判断
                //当个数大于0且不是正在打印中的时候才能打印
                while ((printDetails.IntCount > 0))
                {
                    //如下的才能打印
                    if (!isprintDocument_PrintPage)
                    {
                        ArrayList arrlist = ((queuePrintItemRowAndPages)printDetails.arrlistqueuePrintItemRowAndPages[0]).arrlistRow;
                        int intP = ((queuePrintItemRowAndPages)printDetails.arrlistqueuePrintItemRowAndPages[0]).intPages;
                        int i = PrintBarcode(printDetails.ShapesFileName, arrlist, intP);

                        if (i > 0)
                        {
                            //到这一步就保存打印记录了
                            //记录打印。
                            ClsDataBase myClsDataBase = new ClsDataBase();
                            myClsDataBase.commandAddPrintedRecord(printDetails.strTableName, arrlist, i);

                            OnBarcodePrinted(new printedEventArgs());//发出打印消息
                        }

                        printDetails.arrlistqueuePrintItemRowAndPages.RemoveAt(0);//删除第一项因为已经打印了
                    }

                }

            }
            else
            {
                //到这里就是非充满打印,跟充满打印不同的地方在于这个是一张一张往上打印的
                PrintBarcode2(printDetails);

            }
        }
示例#6
0
        /// <summary>
        /// 加载以前导入的EXCEL表格
        /// </summary>
        private void LoadPreviouslyExCel()
        {
            //这个依旧是新建一个对话框窗体
            FrmLoadExcelRecords f = new FrmLoadExcelRecords();
            if (f.ShowDialog() == DialogResult.OK)
            {
                strTableName = FrmLoadExcelRecords.strTableName;
            }

            //从数据库中导入这个表
            ClsDataBase myClsDataBase = new ClsDataBase();
            LoadDataTable(myClsDataBase.getUserLoadTable(strTableName));
            //还得选择哪个是数量
            loadPrintedQtytoComboBox();
        }
示例#7
0
        private void btnLoadzPreviously_Click(object sender, EventArgs e)
        {
            //这个依旧是新建一个对话框窗体
            FrmLoadExcelRecords f = new FrmLoadExcelRecords();
            if (f.ShowDialog() == DialogResult.OK)
            {
                strCurrentTableName = FrmLoadExcelRecords.strTableName;
            }

            //从数据库中导入这个表
            ClsDataBase myClsDataBase = new ClsDataBase();
            dataGridView1.DataSource = myClsDataBase.getUserLoadTable(strCurrentTableName);

            //还得选择哪个是数量
            loadPrintedQtytoComboBox();
        }
示例#8
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);
            }
        }
示例#9
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());

            }
        }