Example #1
0
 private void Redo(CheckStoreOrder allocateOrder)
 {
     if (this.RedoClick != null)
     {
         this.RedoClick(allocateOrder, this);
     }
 }
Example #2
0
 public CheckStoreDetailCtrl(CheckStoreOrder order, bool isPos)
 {
     InitializeComponent();
     Init();
     this.curCheckStoreOrder = order;
     this.Initialize();
 }
        private void ShowForm(CheckStoreOrder order)
        {
            //采购进货明细
            CostumeStoreTrackSearchProfitDetailForm form
                = new CostumeStoreTrackSearchProfitDetailForm();

            form.BaseModifyCostumeID = costumeID;
            form.ShowDialog(order);
        }
Example #4
0
        internal void ShowDialog(CheckStoreOrder order)
        {
            datastarttime = DateTime.Now;
            this.Initialize(order);
            DateTime endtime = DateTime.Now;
            TimeSpan span    = (TimeSpan)(endtime - starTime);

            CommonGlobalUtil.WriteLog("盘点汇总数盈亏明细界面加载开始时间:" + starTime + " 结束时间:" + endtime + " 总耗时数:" + span.TotalSeconds + "秒");

            this.ShowDialog();
        }
Example #5
0
        private void Cancel(CheckStoreOrder allocateOrder)
        {
            try
            {
                if (GlobalMessageBox.Show("是否确认操作?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
                if (CommonGlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                InteractResult result = null;

                /*  if (IsPos)
                 * {
                 *    GuideSelectForm form = new GuideSelectForm(GuideComboBoxInitializeType.Normal, shopID);
                 *    form.ConfirmClick += form_ConfirmClick;
                 *    form.ShowDialog();
                 * }*/

                userID = CommonGlobalCache.CurrentUserID;
                allocateOrder.CancelUserID = CommonGlobalCache.CurrentUserID;

                result = CommonGlobalCache.ServerProxy.OverrideCheckStore(allocateOrder.ID, userID);
                switch (result?.ExeResult)
                {
                case ExeResult.Success:
                    GlobalMessageBox.Show("冲单成功!");
                    break;

                case ExeResult.Error:
                    GlobalMessageBox.Show(result.Msg);
                    break;

                default:
                    break;
                }
                this.RefreshPage();
            }
            catch (Exception ee)
            {
                ShowError(ee);
            }
            finally
            {
                UnLockPage();
            }
        }
Example #6
0
        private void SetState()
        {
            #region 初始化skinComboBox_State
            List <ListItem <CheckStoreOrderState> > listItems = new List <ListItem <CheckStoreOrderState> >();
            listItems.Add(new ListItem <CheckStoreOrderState>(CommonGlobalUtil.COMBOBOX_ALL, CheckStoreOrderState.All));
            listItems.Add(new ListItem <CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.Approved), CheckStoreOrderState.Approved));
            //listItems.Add(new ListItem<CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.Canceled), CheckStoreOrderState.Canceled));
            //listItems.Add(new ListItem<CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.Expired), CheckStoreOrderState.Expired));
            listItems.Add(new ListItem <CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.PendingReview), CheckStoreOrderState.PendingReview));
            listItems.Add(new ListItem <CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.Suspend), CheckStoreOrderState.Suspend));
            //listItems.Add(new ListItem<CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.TaskIsCancel), CheckStoreOrderState.TaskIsCancel));
            listItems.Add(new ListItem <CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.OverrideOrder), CheckStoreOrderState.OverrideOrder));
            listItems.Add(new ListItem <CheckStoreOrderState>(CheckStoreOrder.GetStateName(CheckStoreOrderState.ChildOrder), CheckStoreOrderState.ChildOrder));

            this.skinComboBox_State.DisplayMember = "Key";
            this.skinComboBox_State.ValueMember   = "Value";
            this.skinComboBox_State.DataSource    = listItems;
            #endregion
        }
Example #7
0
        private void Initialize(CheckStoreOrder order)
        {
            if (order == null || String.IsNullOrEmpty(order.ID))
            {
                return;
            }
            try
            {
                this.Text += "-" + order.ID;
                List <CheckStoreDetail> list = CommonGlobalCache.ServerProxy.GetCheckStoreDetail(order.ID);

                DateTime endtime = DateTime.Now;
                TimeSpan span    = (TimeSpan)(endtime - datastarttime);
                CommonGlobalUtil.WriteLog("盘点汇总数盈亏明细数据加载开始时间:" + datastarttime + " 结束时间:" + endtime + " 总耗时数:" + span.TotalSeconds + "秒");
                starTime = DateTime.Now;
                this.BindingOutboundDetailSource(list);
            }
            catch (Exception ee)
            {
                CommonGlobalUtil.ShowError(ee);
            }
        }
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
     {
         return;
     }
     if (e.RowIndex < 0 || e.ColumnIndex < 0)
     {
         return;
     }
     try
     {
         CheckStoreOrder item = dataGridView1.Rows[e.RowIndex].DataBoundItem as CheckStoreOrder;
         if (e.ColumnIndex == iDDataGridViewTextBoxColumn.Index)
         {
             ShowForm(item);
         }
     }
     catch (Exception ee)
     {
         CommonGlobalUtil.ShowError(ee);
     }
 }
Example #9
0
 private void SelectionChanged(CheckStoreOrder checkStoreOrder)
 {
     try
     {
         if (CommonGlobalUtil.EngineUnconnectioned(this))
         {
             return;
         }
         if (checkStoreOrder == null || String.IsNullOrEmpty(checkStoreOrder.ID))
         {
             return;
         }
         this.skinSplitContainer1.Panel2Collapsed = false;
         this.checkStoreDetailCtrl1.Search(checkStoreOrder, this);
     }
     catch (Exception ee)
     {
         ShowError(ee);
     }
     finally
     {
         UnLockPage();
     }
 }
Example #10
0
        public void DoExport(string path, CheckStoreOrder checkStoreOrder)
        {
            try
            {
                // DataTable listtb1 = (dataGridView1.DataSource as DataTable);

                List <CheckStoreDetail> list = CommonGlobalCache.ServerProxy.GetCheckStoreDetail(checkStoreOrder.ID);
                foreach (CheckStoreDetail Sdetail in list)
                {
                    Sdetail.CostumeName = CommonGlobalCache.GetCostumeName(Sdetail.CostumeID);
                }
                //  List<BoundDetail> list = CommonGlobalCache.ServerProxy.GetOutboundDetail(curReturnOrder.OutboundOrderID);
                // System.Collections.SortedList columns = new System.Collections.SortedList();
                List <String> keys   = new List <string>();
                List <String> values = new List <string>();
                int           ColNum = 0;
                foreach (DataGridViewColumn item in dataGridView1.Columns)
                {
                    if (item.Visible)
                    {
                        if (item.DataPropertyName != "FAtm" && item.DataPropertyName != "SAtm" && item.DataPropertyName != "MAtm" && item.DataPropertyName != "LAtm" &&
                            item.DataPropertyName != "XLAtm" && item.DataPropertyName != "XL2Atm" && item.DataPropertyName != "XL3Atm" && item.DataPropertyName != "XL4Atm" &&
                            item.DataPropertyName != "XL5Atm" && item.DataPropertyName != "XL6Atm" && item.DataPropertyName != "SumCountAtm" && item.DataPropertyName != "XSAtm" &&
                            item.Name != "sumCountDataGridViewTextBoxColumn" && item.DataPropertyName != "Price" && item.DataPropertyName != "SumCountWinLost" && item.DataPropertyName != "SumMoneyWinLost"
                            )
                        {
                            ColNum++;
                            keys.Add(item.DataPropertyName);

                            if (item.HeaderText == "XL2")
                            {
                                item.HeaderText = "2XL";
                            }
                            if (item.HeaderText == "XL3")
                            {
                                item.HeaderText = "3XL";
                            }
                            if (item.HeaderText == "XL4")
                            {
                                item.HeaderText = "4XL";
                            }
                            if (item.HeaderText == "XL5")
                            {
                                item.HeaderText = "5XL";
                            }
                            if (item.HeaderText == "XL6")
                            {
                                item.HeaderText = "6XL";
                            }
                            values.Add(item.HeaderText);
                        }
                    }
                }

                foreach (CheckStoreDetail cItem in list)
                {
                    // cItem.CostumeName = CommonGlobalCache.GetCostumeName(cItem.CostumeID);
                }


                List <CellType> cellList = new List <CellType>();
                NPOIHelper.hsRowCount = 5;



                /*  CellType curCellOrderTitle = new CellType();
                 * curCellOrderTitle.RowIndex = 0;
                 * curCellOrderTitle.CellName = ":";
                 * if (ColNum % 2 == 0)
                 * {
                 *
                 *    curCellOrderTitle.CellMergeNum = ColNum / 2 - 1;
                 * }
                 * else
                 * {
                 *    curCellOrderTitle.CellMergeNum = ColNum / 2;
                 * }
                 * //  curCellOrderTitle.CellMergeNum = 10;
                 * cellList.Add(curCellOrderTitle);
                 */


                CellType curCellOrderTitleValue = new CellType();
                curCellOrderTitleValue.RowIndex = 0;
                curCellOrderTitleValue.CellName = "盘点单";
                curCellOrderTitleValue.Title    = true;


                curCellOrderTitleValue.CellMergeNum = ColNum;

                // curCellOrderTitleValue.CellMergeNum = 12;
                cellList.Add(curCellOrderTitleValue);



                CellType curCellOrder = new CellType();
                curCellOrder.RowIndex     = 1;
                curCellOrder.CellName     = "单号:";
                curCellOrder.CellMergeNum = 1;
                cellList.Add(curCellOrder);



                CellType curCellOrderValue = new CellType();
                curCellOrderValue.RowIndex     = 1;
                curCellOrderValue.CellName     = checkStoreOrder.ID;
                curCellOrderValue.CellMergeNum = 2;
                cellList.Add(curCellOrderValue);

                CellType curCellCreaterUser = new CellType();
                curCellCreaterUser.RowIndex     = 1;
                curCellCreaterUser.CellName     = "店铺";
                curCellCreaterUser.CellMergeNum = 1;
                cellList.Add(curCellCreaterUser);

                CellType curCellCreaterUserValue = new CellType();
                curCellCreaterUserValue.RowIndex     = 1;
                curCellCreaterUserValue.CellName     = checkStoreOrder.ShopName;
                curCellCreaterUserValue.CellMergeNum = 2;
                cellList.Add(curCellCreaterUserValue);



                CellType curCellTime = new CellType();
                curCellTime.RowIndex     = 2;
                curCellTime.CellName     = "操作人";
                curCellTime.CellMergeNum = 1;
                cellList.Add(curCellTime);

                CellType curCellTimeValue = new CellType();
                curCellTimeValue.RowIndex     = 2;
                curCellTimeValue.CellName     = checkStoreOrder.OperatorUserName;
                curCellTimeValue.CellMergeNum = 2;
                cellList.Add(curCellTimeValue);



                CellType curCellSource = new CellType();
                curCellSource.RowIndex     = 2;
                curCellSource.CellName     = "审核人:";
                curCellSource.CellMergeNum = 1;
                cellList.Add(curCellSource);



                CellType curCellSourceValue = new CellType();
                curCellSourceValue.RowIndex     = 2;
                curCellSourceValue.CellName     = checkStoreOrder.CheckUserName;
                curCellSourceValue.CellMergeNum = 2;
                cellList.Add(curCellSourceValue);


                CellType curCellTarget = new CellType();
                curCellTarget.RowIndex     = 3;
                curCellTarget.CellName     = "盘点时间:";
                curCellTarget.CellMergeNum = 1;
                cellList.Add(curCellTarget);



                CellType curCellTargetValue = new CellType();
                curCellTargetValue.RowIndex     = 3;
                curCellTargetValue.CellName     = checkStoreOrder.CreateTime.GetDateTimeFormats('f')[0].ToString();;
                curCellTargetValue.CellMergeNum = 2;
                cellList.Add(curCellTargetValue);



                CellType curCellTotal = new CellType();
                curCellTotal.RowIndex     = 3;
                curCellTotal.CellName     = "审核时间:";
                curCellTotal.CellMergeNum = 1;
                cellList.Add(curCellTotal);



                CellType curCellTotalValue = new CellType();
                curCellTotalValue.RowIndex     = 3;
                curCellTotalValue.CellName     = checkStoreOrder.CheckTime.GetDateTimeFormats('f')[0].ToString();;
                curCellTotalValue.CellMergeNum = 2;
                cellList.Add(curCellTotalValue);



                CellType curCellRemark = new CellType();
                curCellRemark.RowIndex     = 4;
                curCellRemark.CellName     = "备注:";
                curCellRemark.CellMergeNum = 1;
                cellList.Add(curCellRemark);



                CellType curCellRemarkValue = new CellType();
                curCellRemarkValue.RowIndex     = 4;
                curCellRemarkValue.CellName     = checkStoreOrder.Remarks.ToString();
                curCellRemarkValue.CellMergeNum = 8;
                cellList.Add(curCellRemarkValue);



                NPOIHelper.CellValues = cellList;


                NPOIHelper.Keys   = keys.ToArray();
                NPOIHelper.Values = values.ToArray();
                NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path);

                GlobalMessageBox.Show("导出完毕!");
            }
            catch (Exception ex)
            { ShowError(ex); }
            finally
            {
                UnLockPage();
            }
        }
Example #11
0
 public void Search(CheckStoreOrder order, BaseModifyUserControl SourcePage)
 {
     this.curCheckStoreOrder = order;
     SourceControl           = SourcePage;
     this.Initialize();
 }
Example #12
0
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }
            DataGridViewUtil.CellFormatting_ReportShowZero(e, this.ReportShowZero);

            DataGridViewRow row   = dataGridView1.Rows[e.RowIndex];
            CheckStoreOrder order = (CheckStoreOrder)row.DataBoundItem;

            if (ColumnDelete.Index == e.ColumnIndex || ColumnEdit.Index == e.ColumnIndex)
            {
                //已取消,不能修改
                CheckStoreOrderState orderState = (CheckStoreOrderState)order.State;
                if (orderState == CheckStoreOrderState.TaskIsCancel || orderState == CheckStoreOrderState.OverrideOrder)
                {
                    e.Value = null;
                }
                //else if (
                //    order.ShopID != CommonGlobalCache.CurrentShopID
                //    )
                ////  && !CommonGlobalUtil.IsAdminUser(order.OperatorUserID))
                //{    //店铺是自己的可以删可以改,
                //     //失效、退回、挂单可以删除
                //     //是管理端发起的盘点,POS端不能修改删除
                //    e.Value = null;
                //}
                else if ((CheckStoreOrderState)order.State == CheckStoreOrderState.Approved)
                {
                    //审核待审核不能删除,并且店铺不是自己的
                    //shopID=null 这是总仓
                    e.Value = null;
                }
            }
            else if (createTimeDataGridViewTextBoxColumn.Index == e.ColumnIndex)
            {
                if ((CheckStoreOrderState)order.State == CheckStoreOrderState.Suspend)
                {
                    e.Value = null;
                }
            }
            else if (e.ColumnIndex == ColumnCancel.Index)
            {
                if (
                    //IsPos ||
                    (CheckStoreOrderState)order.State != CheckStoreOrderState.Approved ||
                    (CheckStoreOrderState)order.State == CheckStoreOrderState.ChildOrder /*|| order.ShopID != CommonGlobalCache.CurrentShopID*/)
                {
                    e.Value = null;
                }
            }
            else if (e.ColumnIndex == ColumnRedo.Index)
            {
                if ((CheckStoreOrderState)order.State != CheckStoreOrderState.OverrideOrder
                    //  || order.ShopID != CommonGlobalCache.CurrentShopID
                    || (CheckStoreOrderState)order.State == CheckStoreOrderState.ChildOrder)
                {
                    e.Value = null;
                }
            }
            else if (e.ColumnIndex == ColumnPrint.Index)
            {
                if ((CheckStoreOrderState)order.State == CheckStoreOrderState.ChildOrder)
                {
                    e.Value = null;
                }
            }
        }
Example #13
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
            {
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            List <CheckStoreOrder> list            = (List <CheckStoreOrder>) this.dataGridView1.DataSource;
            CheckStoreOrder        checkStoreOrder = list[e.RowIndex];

            if (e.ColumnIndex == iDDataGridViewTextBoxColumn.Index)
            {
                if (currentCheckStoreOrder != checkStoreOrder)
                {
                    currentCheckStoreOrder = checkStoreOrder;
                    SelectionChanged(checkStoreOrder);
                }

                if (checkStoreOrder == null || String.IsNullOrEmpty(checkStoreOrder.ID))
                {
                    return;
                }
            }
            else if (e.ColumnIndex == ColumnEdit.Index)
            {
                this.UpdateCheckStoreOrderClick?.Invoke(checkStoreOrder, this);
            }
            else if (e.ColumnIndex == ColumnDelete.Index)
            {
                try
                {
                    //删除
                    if (GlobalMessageBox.Show("确定删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        if (CommonGlobalUtil.EngineUnconnectioned(this))
                        {
                            return;
                        }
                        DeleteCheckStoreResult result = CommonGlobalCache.ServerProxy.DeleteCheckStore(checkStoreOrder.ID);
                        switch (result)
                        {
                        case DeleteCheckStoreResult.Success:
                            GlobalMessageBox.Show("删除成功!");
                            //含统计信息,从刷界面
                            dataGridViewPagingSumCtrl_CurrentPageIndexChanged(this.pagePara.PageIndex);
                            break;

                        case DeleteCheckStoreResult.StateIsPendingReviewOrApproved:
                            GlobalMessageBox.Show("状态是待审核或已审核,不能删除");
                            break;

                        case DeleteCheckStoreResult.Error:
                            GlobalMessageBox.Show("内部错误!");
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ee)
                {
                    ShowError(ee);
                }
                finally
                {
                    UnLockPage();
                }
            }
            else if (ColumnCancel.Index == e.ColumnIndex)
            {
                this.Cancel(checkStoreOrder);
            }
            else if (ColumnRedo.Index == e.ColumnIndex)
            {
                this.Redo(checkStoreOrder);
            }
            else if (e.ColumnIndex == ColumnPrint.Index)
            {
                //打印
                if (currentCheckStoreOrder != checkStoreOrder)
                {
                    currentCheckStoreOrder = checkStoreOrder;
                    SelectionChanged(checkStoreOrder);
                }

                if (checkStoreOrder == null || String.IsNullOrEmpty(checkStoreOrder.ID))
                {
                    return;
                }
                checkStoreDetailCtrl1?.Print();
            }
            else if (e.ColumnIndex == Column1.Index)
            {
                //导出
                path = CJBasic.Helpers.FileHelper.GetPathToSave("保存文件", "盘点单" + checkStoreOrder.ID + new Date(DateTime.Now).ToDateInteger() + ".xls", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                if (String.IsNullOrEmpty(path))
                {
                    return;
                }

                // this.CheckStoreDetailExcept?.Invoke(checkStoreOrder, this, path);
                checkStoreDetailCtrl1?.DoExport(path, checkStoreOrder);
            }
        }
Example #14
0
        //简单打印示例
        public static void Print(CheckStoreOrder item, DataGridView dataGridView2, int times = 1)
        {
            //if (times < 0) { times = 0; }

            //for (int i = 0; i < times; i++)
            //{
            InteractResult <PrintTemplateInfo> result = CommonGlobalCache.ServerProxy.GetPrintTemplateInfo(PrintTemplateType.CheckStoreOrder);

            if (result.ExeResult == ExeResult.Success)
            {
                PrintTemplateInfo CurrentPTemplate = result.Data;
                for (int c = 0; c < CurrentPTemplate.PrintCount; c++)
                {
                    GoldPrinter.MisGoldPrinter misGoldPrinter = new GoldPrinter.MisGoldPrinter(false, new PrinterMargins(20, 20, 20, 20, 800, 1129));
                    // misGoldPrinter.RowsPerPage = 3;
                    if (CurrentPTemplate.OrderName != "")
                    {
                        misGoldPrinter.Title = CurrentPTemplate.OrderName; //主标题(C#用\n表示换行)	}

                        misGoldPrinter.Caption = "";

                        double headRow = Math.Round(Convert.ToSingle(CurrentPTemplate.SystemVariables.Count / 2));

                        Header header = new Header(Convert.ToInt32(headRow) + 1, 2);
                        header.IsDrawAllPage = true;

                        CommonGlobalUtil.WriteLog("变量总数=" + CurrentPTemplate.SystemVariables.Count + "\r\n" + "应显示行号=" + headRow + 1);

                        //            misGoldPrinter.Title = "盘点单";                           //主标题(C#用\n表示换行)
                        //misGoldPrinter.Caption = "";                                        //副标题
                        //misGoldPrinter.Top = "单号:" + item.AllocateOrder.ID + "|收货方:" + CommonGlobalCache.GetShopName(item.AllocateOrder.DestShopID) + "|开单日期:" + item.AllocateOrder.CreateTime;                                       //抬头,一行三列的文字说明,用|分隔


                        // Header header = new Header(4, 3);                   //行列数基本不受限制,但超过一页失去意义,因为以Body为主,以其它为辅
                        //header.IsDrawAllPage = true;                        //可以指定每页是否重复打印

                        for (int i = 0; i < CurrentPTemplate.SystemVariables.Count; i++)
                        {
                            int curR = 0;
                            if (i < 2)
                            {
                                curR = 0;
                            }
                            else
                            {
                                double resRow = i / 2;
                                curR = Convert.ToInt32(Math.Round(resRow));
                            }
                            string KeyStr = "";
                            if (CurrentPTemplate.SystemVariables[i] == "单号")
                            {
                                KeyStr = "盘点单号:";
                                header.SetText(curR, i % 2, CurrentPTemplate.SystemVariables[i] + item.ID);
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "店铺")
                            {
                                KeyStr = "店 铺:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetShopName(item.ShopID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "操作人")
                            {
                                KeyStr = "操 作 人:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetUserName(item.OperatorUserID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "审核人")
                            {
                                KeyStr = "审 核 人:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetUserName(item.CheckUserID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "盘点时间")
                            {
                                KeyStr = "盘点时间:";
                                header.SetText(curR, i % 2, KeyStr + item.CreateTime.GetDateTimeFormats('f')[0].ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "审核时间")
                            {
                                KeyStr = "审核时间:";
                                header.SetText(curR, i % 2, KeyStr + item.CheckTime.GetDateTimeFormats('f')[0].ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "单据备注")
                            {
                                KeyStr = "备    注:";
                                header.SetText(curR, i % 2, KeyStr + item.Remarks.ToString());
                            }
                        }


                        //   header.SetText(0, 0, "盘点单号:" + item.ID);
                        //  header.SetText(0, 1, "任务编号:" + item.CheckStoreTaskID);

                        /*    header.SetText(0, 2, String.Empty);
                         *  header.SetText(1, 0, "店    铺:" + CommonGlobalCache.GetShopName(item.ShopID));
                         *  header.SetText(1, 1, "操 作 人:" + CommonGlobalCache.GetUserName(item.OperatorUserID));
                         *  header.SetText(1, 2, "审 核 人:" + CommonGlobalCache.GetUserName(item.CheckUserID));           //同仁们还可以根据实际应用对GridBase的DataSource进行扩展
                         *  header.SetText(2, 0, "盘点时间:" + item.CreateTime.GetDateTimeFormats('f')[0].ToString());
                         *  header.SetText(2, 1, "审核时间:" + item.CheckTime.GetDateTimeFormats('f')[0].ToString());
                         *  header.SetText(2, 2, String.Empty);
                         *  header.SetText(3, 0, "备    注:");
                         *  header.SetText(3, 1, item.Remarks);
                         *  header.SetText(3, 2, String.Empty);*/

                        misGoldPrinter.Header = header;                     //将定制对象,赋给页头
                                                                            // misGoldPrinter.Top = new String[] { "单号:" + item.AllocateOrder.ID + "|收货方:" + CommonGlobalCache.GetShopName(item.AllocateOrder.DestShopID) + "|开单日期:" + item.AllocateOrder.CreateTime,
                                                                            //  "发货方:" + CommonGlobalCache.GetShopName(item.AllocateOrder.SourceShopID) + "|操作人:" + CommonGlobalCache.GetUserName(item.AllocateOrder.SourceUserID) + "|打印日期:" + System.DateTime.Now.ToLongDateString()  };                                       //抬头,一行三列的文字说明,用|分隔


                        //  misGoldPrinter.Bottom = "发货方:" + CommonGlobalCache.GetShopName(item.AllocateOrder.SourceShopID) + "|操作人:" + CommonGlobalCache.GetUserName(item.AllocateOrder.SourceUserID) + "|打印日期:" + System.DateTime.Now.ToLongDateString() + "|";  //结尾,说明同抬头
                        List <PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;
                        bool   isflag      = false;
                        string ColumnsList = string.Empty;
                        foreach (PrintColumnInfo itemC in dataGV)
                        {
                            ColumnsList += itemC.Name + ",";
                        }
                        CommonGlobalUtil.WriteLog("模板设置打印列表头为=" + ColumnsList + "\r\n");
                        if (dataGV.Count == 0)
                        {
                            isflag = true;
                        }
                        //   DataTable dt = dataGridView2.DataSource as DataTable;
                        //  DataTable newDt = new DataTable();
                        List <int> columnCount         = new List <int>();
                        int        pinrtColNum         = 0;
                        string     dataGridColumnsList = string.Empty;
                        for (int i = 0; i < dataGridView2.Columns.Count; i++)
                        {
                            DataGridViewColumn column = dataGridView2.Columns[i];
                            if (column.DataPropertyName == "FAtm" || column.DataPropertyName == "XSAtm" || column.DataPropertyName == "SAtm" || column.DataPropertyName == "MAtm" ||
                                column.DataPropertyName == "LAtm" || column.DataPropertyName == "XLAtm" || column.DataPropertyName == "XL2Atm" || column.DataPropertyName == "XL3Atm" ||
                                column.DataPropertyName == "XL4Atm" || column.DataPropertyName == "XL5Atm" || column.DataPropertyName == "XL6Atm")
                            {
                                column.Visible = false;
                                continue;
                            }
                            //if (column.Visible==true)
                            //{
                            if (dataGV.FindAll(t => t.Name == column.HeaderText).Count > 0)
                            {
                                columnCount.Add(i);
                                dataGridColumnsList += column.HeaderText + ",";
                                pinrtColNum++;
                            }
                            else
                            {
                                if (dataGV.FindAll(t => t.Name == column.DataPropertyName).Count > 0)
                                {
                                    columnCount.Add(i);
                                    column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                    dataGridColumnsList += column.DataPropertyName + ",";
                                    pinrtColNum++;
                                }
                                else
                                {
                                    if (column.DataPropertyName.Contains("XL"))
                                    {
                                        string name = column.DataPropertyName;      //XL3
                                                                                    //3XL
                                        string newname  = name.Replace("XL", "");
                                        string checkstr = newname + "XL";
                                        if (dataGV.FindAll(t => t.Name == checkstr).Count > 0)
                                        {
                                            columnCount.Add(i);
                                            column.HeaderText    = column.HeaderText.Replace("\r\n", " ");
                                            dataGridColumnsList += column.DataPropertyName + ",";
                                            pinrtColNum++;
                                        }
                                        else
                                        {
                                            column.Visible = false;
                                        }
                                    }
                                    else
                                    {
                                        column.Visible = false;
                                    }
                                }
                            }

                            if (isflag)
                            {
                                if (i == 0)
                                {
                                    columnCount.Add(i);
                                    column.Visible    = true;
                                    column.HeaderText = "";

                                    DataTable  dt = new DataTable();
                                    DataColumn c1 = new DataColumn();
                                    c1.ColumnName = "HeaderText";

                                    dt.Columns.Add(c1);
                                    dataGridView2.DataSource = null;
                                    dataGridView2.DataSource = dt;
                                }
                            }
                            //}
                        }

                        CommonGlobalUtil.WriteLog("DataGridView能打印的列为=" + dataGridColumnsList);
                        misGoldPrinter.DataSource = DataGridViewUtil.ToStringArray(dataGridView2, true, true);
                        if (!Directory.Exists(CommonGlobalUtil.SystemDir + "EXPORTS\\"))
                        {
                            Directory.CreateDirectory(CommonGlobalUtil.SystemDir + "EXPORTS\\");
                        }
                        misGoldPrinter.FileName = CommonGlobalUtil.SystemDir + "EXPORTS\\" + item.ID + ".jpg";
                        ((GoldPrinter.Body)(misGoldPrinter.Body)).Font = dataGridView2.Font;

                        /*  int[] widths = new int[] {
                         * 80,100,50,40, 50,
                         * 30,30,30,30,30,30,30,30,30,30,30
                         * ,40,50,50
                         * };*/
                        int[] widths = new int[CurrentPTemplate.PrintColumnInfos.Count];
                        for (int j = 0; j < CurrentPTemplate.PrintColumnInfos.Count; j++)
                        {
                            widths[j] = Convert.ToInt32(CurrentPTemplate.PrintColumnInfos[j].Rate);
                        }

                        List <int> widthList = new List <int>();
                        for (int i = 0; i < CurrentPTemplate.PrintColumnInfos.Count; i++)
                        {
                            DataGridViewColumn column = dataGridView2.Columns[columnCount[i]];
                            if (column.Visible && !String.IsNullOrEmpty(column.HeaderText))
                            {
                                widthList.Add(widths[i]);
                            }
                        }

                        if (isflag)
                        {
                            widths    = new int[1];
                            widths[0] = 100;
                            widthList.Add(widths[0]);
                        }
                        widths = widthList.ToArray();
                        int newWidth = 800;

                        /*  int totalWidth = 0;
                         * for (int i = 0; i < widths.Length; i++)
                         * {
                         *    totalWidth += widths[i];
                         * }*/
                        for (int i = 0; i < widths.Length; i++)
                        {
                            widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                            // widths[i] = decimal.ToInt32(Math.Round((widths[i] * newWidth * (decimal)1.0 / totalWidth), 0, MidpointRounding.AwayFromZero));
                        }

                        CommonGlobalUtil.WriteLog("实际打印数量=" + pinrtColNum + "\r\n" + "设置能打印的列数量=" + widths.Length.ToString());
                        ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth = widths;
                        misGoldPrinter.Preview();
                        misGoldPrinter.Dispose();
                        misGoldPrinter = null;
                    }
                }
            }
        }