예제 #1
0
 private void dataGridView1_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         PurchaseOrder order = (PurchaseOrder)this.dataGridView1.CurrentRow.DataBoundItem;
         if (order != null && order != curOrder)
         {
             List <BoundDetail> curInboundDetailList = GlobalCache.ServerProxy.GetPurchaseDetails(order.ID);
             if (curInboundDetailList != null)
             {
                 foreach (BoundDetail item in curInboundDetailList)
                 {
                     Costume costume = CommonGlobalCache.GetCostume(item.CostumeID);
                     item.SupplierName = CommonGlobalCache.GetSupplierName(item.SupplierID) ?? item.SupplierID;
                     if (costume != null)
                     {
                         item.BrandName   = CommonGlobalCache.GetBrandName(costume.BrandID);
                         item.CostumeName = costume.Name;
                     }
                 }
             }
             // dataGridView2.DataSource = null;
             // dataGridView2.DataSource = curInboundDetailList;
             dataGridViewPagingSumCtrl1.BindingDataSource(curInboundDetailList);
             curOrder = order;
         }
     }
     catch (Exception ex)
     {
         //  CommonGlobalUtil.ShowError(ex);
     }
 }
 /// <summary>
 /// 将集合中GuideName赋值
 /// </summary>
 /// <param name="memberList"></param>
 private void SetOtherValue(List <Costume> list)
 {
     foreach (Costume item in list)
     {
         String name = CommonGlobalCache.GetSupplierName(item.SupplierID);
         item.SupplierName = name;
         item.BrandName    = CommonGlobalCache.GetBrandName(item.BrandID);
     }
 }
예제 #3
0
        private void SkinTxt_TextChanged(object sender, EventArgs e)
        {
            if (this.Text.Contains("costumeInfoText") || this.SkinTxt.Text.Contains("costumeInfoText"))
            {
                this.Text = ""; this.SkinTxt.Text = ""; return;
            }
            if (this.Text != "costumeInfoText1" && this.SkinTxt.Text != "costumeInfoText1")
            {
                if (String.IsNullOrEmpty(this.Text))
                {
                    this.CostumeSelected?.Invoke(null, false);
                }
                else
                {
                    string costumeID = this.Text.Trim();

                    //条形码,先根据条形码获取款号
                    //List<BarCode> barCodes = CommonGlobalCache.BarCodeList?.FindAll(t => t.BarCodeValue.ToUpper().Equals(costumeID.ToUpper()));

                    ////,条形码为一条,找到这个款号
                    //if (barCodes != null && barCodes.Count == 1)
                    //{
                    //    costumeID = barCodes[0].CostumeID;
                    //    isBarCode = true;
                    //}
                    //BarCode4Costume costume = CommonGlobalUtil.GetBarCode(costumeID);
                    //if (costume != null)
                    //{
                    //    costumeID = costume.CostumeID;
                    //    SkinTxt.Text = costume.BarCode;
                    //    isBarCode = true;
                    //}

                    List <Costume> resultList = CommonGlobalCache.CostumeList.FindAll(t => t.ID.ToUpper().Equals(costumeID.ToUpper()));

                    if (filterValid)
                    {
                        resultList = resultList.FindAll(t => t.IsValid);
                    }

                    if (resultList == null || resultList.Count == 0)
                    {
                        this.CostumeSelected?.Invoke(null, false);

                        return;
                    }
                    if (resultList.Count == 1)
                    {
                        resultList[0].BrandName    = CommonGlobalCache.GetBrandName(resultList[0].BrandID);
                        resultList[0].SupplierName = CommonGlobalCache.GetSupplierName(resultList[0].SupplierID);
                        CostumeSelected?.Invoke(resultList[0], false);
                    }
                }
            }
        }
예제 #4
0
        private void SetDataSource(List <Costume> items)
        {
            this.dataGridView1.DataSource = null;
            this.currentCostumes          = items;
            this.currentSource.Clear();
            for (int i = 0; i < items.Count; i++)
            {
                items[i].BrandName    = CommonGlobalCache.GetBrandName(items[i].BrandID);
                items[i].SupplierName = CommonGlobalCache.GetSupplierName(items[i].SupplierID);
                this.currentSource.Add(items[i]);
            }

            this.dataGridView1.DataSource = this.currentSource;
        }
예제 #5
0
 private void BindingSource(List <BoundDetail> list)
 {
     this.dataGridView2.DataSource = null;
     if (list != null && list.Count > 0)
     {
         foreach (var item in list)
         {
             Costume costume = CommonGlobalCache.GetCostume(item.CostumeID);
             item.SupplierName = CommonGlobalCache.GetSupplierName(item.SupplierID);
             item.BrandName    = CommonGlobalCache.GetBrandName(costume.BrandID);
             item.Year         = costume.Year;
             item.Season       = costume.Season;
             item.CostumeName  = costume.Name;
         }
         dataGridViewPagingSumCtrl2.BindingDataSource <BoundDetail>(DataGridViewUtil.ListToBindingList(curDetailList));
         //this.dataGridView2.DataSource = list;
     }
 }
예제 #6
0
 private void SetDataSource(List <CostumeItem> items)
 {
     this.currentCostumeitems = items;
     this.currentSource.Clear();
     for (int i = 0; i < items.Count; i++)
     {
         items[i].Costume.BrandName    = CommonGlobalCache.GetBrandName(items[i].Costume.BrandID);
         items[i].Costume.SupplierName = CommonGlobalCache.GetSupplierName(items[i].Costume.SupplierID);
         if (items[i].CostumeStoreList != null)
         {
             foreach (var item in items[i].CostumeStoreList)
             {
                 item.CostumeName = items[i].Costume.Name;
                 item.BrandName   = items[i].Costume.BrandName;
                 item.Price       = items[i].Costume.Price;
             }
         }
         this.currentSource.Add(items[i].Costume);
     }
     this.dataGridView1.DataSource = null;
     this.dataGridView1.DataSource = this.currentSource;
 }
예제 #7
0
 private void dataGridView1_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         if (flag == false)
         {
             if (this.dataGridView1.CurrentRow.DataBoundItem != null && this.dataGridView1.Rows.Count > 0)
             {
                 AllocateOrder order = (AllocateOrder)this.dataGridView1.CurrentRow.DataBoundItem;
                 if (order != null && order != curOrder)
                 {
                     List <BoundDetail> list = CommonGlobalCache.ServerProxy.GetOutboundDetail(order.OutboundOrderID);
                     if (list != null && list.Count > 0)
                     {
                         foreach (var item in list)
                         {
                             Costume costume = CommonGlobalCache.GetCostume(item.CostumeID);
                             item.SupplierName = CommonGlobalCache.GetSupplierName(item.SupplierID);
                             item.BrandName    = CommonGlobalCache.GetBrandName(costume.BrandID);
                             item.CostumeName  = costume.Name;
                         }
                     }
                     dataGridViewPagingSumCtrl1.BindingDataSource(list);
                     curOrder = order;
                 }
             }
         }
         else
         {
             flag = false;
         }
     }
     catch (Exception ex)
     {
         //   CommonGlobalUtil.ShowError(ex);
     }
 }
예제 #8
0
        public PurchaseOrderPickForm(bool isPurchase)
        {
            InitializeComponent();
            dataGridViewPagingSumCtrl = new DataGridViewPagingSumCtrl(this.dataGridView1);
            dataGridViewPagingSumCtrl.ShowRowCounts = false;
            dataGridViewPagingSumCtrl.Initialize();
            dataGridViewPagingSumCtrl1 = new DataGridViewPagingSumCtrl(this.dataGridView2);
            dataGridViewPagingSumCtrl1.ShowRowCounts = false;
            dataGridViewPagingSumCtrl1.Initialize();
            GetHangUpPurchasesPara para = new GetHangUpPurchasesPara()
            {
                IsPurchase = isPurchase
            };

            if (isPurchase)
            {
                this.Text = "采购进货单提单";
            }
            else
            {
                this.Text = "采购退货单提单";
            }

            orders = GlobalCache.ServerProxy.GetHangUpPurchases(para);
            if (orders != null)
            {
                foreach (var item in orders)
                {
                    item.SupplierName = CommonGlobalCache.GetSupplierName(item.SupplierID);
                    item.UserName     = CommonGlobalCache.GetUserName(item.AdminUserID);
                    item.ShopName     = CommonGlobalCache.GetShopName(item.DestShopID);
                }
            }

            dataGridViewPagingSumCtrl.BindingDataSource(orders);
        }
예제 #9
0
        private void SkinTxt_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }
            try
            {
                isBarCode = false;
                string costumeID = this.SkinTxt.Text.Trim();
                if (string.IsNullOrEmpty(costumeID))
                {
                    if (this.CostumeSelected != null)
                    {
                        this.CostumeSelected(null);
                    }
                    return;
                }
                if (CommonGlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                //条形码,先根据条形码获取款号
                //List<BarCode> barCodes = CommonGlobalCache.BarCodeList?.FindAll(t => t.BarCodeValue.ToUpper().Equals(costumeID.ToUpper()));

                ////,条形码为一条,找到这个款号
                //if (barCodes != null && barCodes.Count == 1)
                //{
                //    costumeID = barCodes[0].CostumeID;
                //    this.SkinTxt.Text = barCodes[0].BarCodeValue;
                //    isBarCode = true;
                //}
                if (costumeID.Length == 15)
                {
                    BarCode4Costume costume = CommonGlobalUtil.GetBarCode(costumeID);
                    if (costume != null)
                    {
                        costumeID    = costume.CostumeID;
                        SkinTxt.Text = costume.BarCode;
                        isBarCode    = true;
                    }
                }



                List <Costume> resultList = CommonGlobalCache.CostumeList.FindAll(t => t.ID.ToUpper().Contains(costumeID.ToUpper()) && t.IsValid == true);
                //  List<CostumeItem> resultList = GlobalCache.ServerProxy.GetPfCustomerStores("", costumeID);
                if (resultList == null || resultList.Count == 0)
                {
                    this.CostumeSelected?.Invoke(null);
                    //this.SkinTxt.Text = "";

                    return;
                }
                if (resultList.Count == 1)
                {
                    List <CostumeItem> OneresultList = GlobalCache.ServerProxy.GetPfCustomerStores(CustomerID, costumeID, true);
                    if (OneresultList.Count == 0)
                    {
                        CostumeItem createItem = new CostumeItem();

                        createItem.Costume          = resultList[0];
                        createItem.CostumeStoreList = SetupStores(resultList[0]);
                        OneresultList.Add(createItem);
                    }
                    OneresultList[0].Costume.BrandName    = CommonGlobalCache.GetBrandName(OneresultList[0].Costume.BrandID);
                    OneresultList[0].Costume.SupplierName = CommonGlobalCache.GetSupplierName(OneresultList[0].Costume.SupplierID);
                    if (OneresultList[0].CostumeStoreList != null)
                    {
                        foreach (var item in OneresultList[0].CostumeStoreList)
                        {
                            item.CostumeName = OneresultList[0].Costume.Name;
                            item.BrandName   = OneresultList[0].Costume.BrandName;
                            item.Price       = OneresultList[0].Costume.Price;
                        }
                    }


                    if (!isBarCode)
                    {
                        this.SkinTxt.Text = OneresultList[0].Costume.ID;
                    }
                    if (this.CostumeSelected != null)
                    {
                        this.CostumeSelected(OneresultList[0]);
                    }
                }
                else
                {
                    PfCostumeFromShopForm costumeForm = new PfCostumeFromShopForm(resultList, costumeID, CustomerID, filterValid);
                    //   costumeForm.Hide();
                    // costumeForm.CostumeSelected += CostumeForm_CostumeSelected;
                    if (costumeForm.ShowDialog() == DialogResult.OK)
                    {
                        if (costumeForm.Result == null)
                        {
                            return;
                        }
                        this.SkinTxt.Text = costumeForm.Result.Costume.ID;
                        CostumeSelected?.Invoke(costumeForm.Result);
                    }
                }
            }
            catch (Exception ee)
            {
                ShowError(ee);
            }
            finally
            {
                UnLockPage();
            }
        }
예제 #10
0
        public void Search()
        {
            try
            {
                isBarCode = false;

                string costumeID = this.SkinTxt.Text.Trim();
                if (string.IsNullOrEmpty(costumeID))
                {
                    if (this.CostumeSelected != null)
                    {
                        this.CostumeSelected(null, true);
                    }
                    return;
                }

                if (CommonGlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }

                //条形码,先根据条形码获取款号
                //List<BarCode> barCodes = CommonGlobalCache.BarCodeList?.FindAll(t => t.BarCodeValue.ToUpper().Equals(costumeID.ToUpper()));

                ////,条形码为一条,找到这个款号
                //if (barCodes != null && barCodes.Count == 1)
                //{
                //    costumeID = barCodes[0].CostumeID;
                //    this.SkinTxt.Text = barCodes[0].BarCodeValue;
                //    isBarCode = true;
                //}
                //String barCode=

                /*   if (costumeID.Length == 15)
                 * {
                 *     BarCode4Costume costume = CommonGlobalUtil.GetBarCode(costumeID);
                 *     if (costume != null)
                 *     {
                 *         costumeID = costume.CostumeID;
                 *         SkinTxt.Text = costume.BarCode;
                 *         isBarCode = true;
                 *     }
                 * }*/

                List <Costume> resultList = CommonGlobalCache.CostumeList.FindAll(t => t.ID.ToUpper().Equals(costumeID.ToUpper()));
                if (filterValid)
                {
                    resultList = resultList.FindAll(t => t.IsValid);
                }
                if (resultList == null || resultList.Count == 0)
                {
                    if (this.CostumeSelected != null)
                    {
                        this.CostumeSelected(null, true);
                    }
                    return;
                }
                if (resultList.Count == 1)
                {
                    resultList[0].BrandName    = CommonGlobalCache.GetBrandName(resultList[0].BrandID);
                    resultList[0].SupplierName = CommonGlobalCache.GetSupplierName(resultList[0].SupplierID);
                    if (!isBarCode)
                    {
                        this.SkinTxt.Text = resultList[0].ID;
                    }
                    if (this.CostumeSelected != null)
                    {
                        this.CostumeSelected(resultList[0], true);
                    }
                }
                else
                {
                    /*  CostumeForm costumeForm = new CostumeForm(resultList, costumeID, filterValid);
                     * //   costumeForm.CostumeSelected += CostumeForm_CostumeSelected;
                     * if (costumeForm.ShowDialog() == DialogResult.OK)
                     * {
                     *    this.SkinTxt.Text = costumeForm.Result.ID;
                     *    CostumeSelected?.Invoke(costumeForm.Result, true);
                     * }*/
                }
            }
            catch (Exception ee)
            {
                ShowError(ee);
            }
            finally
            {
                UnLockPage();
            }
        }
예제 #11
0
        private void DoExport()
        {
            try
            {
                List <SupplierAccountContrastInfo> unableStore = new List <SupplierAccountContrastInfo>();
                List <SupplierAccountContrastInfo> stores      = new List <SupplierAccountContrastInfo>();
                List <SupplierAccountContrastInfo> list        = (List <SupplierAccountContrastInfo>)dataGridView1.DataSource;
                System.Collections.SortedList      columns     = new System.Collections.SortedList();
                List <String> keys   = new List <string>();
                List <String> values = new List <string>();

                foreach (DataGridViewColumn item in dataGridView1.Columns)
                {
                    //if (IsPos)
                    //{
                    //    if (item.Index == CostPrice.Index || item.Index == SumCostMoney.Index)
                    //    {
                    //        continue;
                    //    }
                    //}
                    if (item.Visible)
                    {
                        if (item.DataPropertyName == "InCount")
                        {
                            keys.Add(item.DataPropertyName);
                            //  values.Add("发货\r\n" + item.HeaderText);
                            values.Add("发货" + item.HeaderText);
                        }
                        else if (item.DataPropertyName == "InMoney")
                        {
                            keys.Add(item.DataPropertyName);
                            // values.Add("发货\r\n" + item.HeaderText);
                            values.Add("发货" + item.HeaderText);
                        }
                        else if (item.DataPropertyName == "OutCount")
                        {
                            keys.Add(item.DataPropertyName);
                            //values.Add("退货\r\n" + item.HeaderText);
                            values.Add("退货" + item.HeaderText);
                        }
                        else if (item.DataPropertyName == "OutMoney")
                        {
                            keys.Add(item.DataPropertyName);
                            //values.Add("退货\r\n" + item.HeaderText);
                            values.Add("退货" + item.HeaderText);
                        }
                        else
                        {
                            keys.Add(item.DataPropertyName);
                            values.Add(item.HeaderText);
                        }
                    }
                }

                List <CellType> cellList = new List <CellType>();
                NPOIHelper.hsRowCount = 1;
                CellType curCell = new CellType();
                curCell.RowIndex     = 0;
                curCell.CellName     = "供应商:" + CommonGlobalCache.GetSupplierName(ValidateUtil.CheckEmptyValue(skinComboBoxSupplier.SelectedValue));
                curCell.CellMergeNum = 4;
                cellList.Add(curCell);

                CellType curCellTime = new CellType();
                curCellTime.RowIndex     = 0;
                curCellTime.CellName     = "业务时间:" + new CJBasic.Date(this.dateTimePicker_Start.Value) + "至" + new CJBasic.Date(this.dateTimePicker_End.Value);
                curCellTime.CellMergeNum = 6;
                cellList.Add(curCellTime);

                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();
            }
        }
예제 #12
0
        private void SkinTxt_TextChanged(object sender, EventArgs e)
        {
            //if (EnableTextChanged)
            //{
            if (String.IsNullOrEmpty(this.Text))
            {
                if (this.CostumeSelected != null)
                {
                    curItem = null;
                    this.CostumeSelected(curItem, false);
                }
            }
            else
            {
                string costumeID = this.Text.Trim();
                ////条形码,先根据条形码获取款号
                //List<BarCode> barCodes = CommonGlobalCache.BarCodeList?.FindAll(t => t.BarCodeValue.ToUpper().Equals(costumeID.ToUpper()));

                ////,条形码为一条,找到这个款号
                //if (barCodes != null && barCodes.Count == 1)
                //{
                //    costumeID = barCodes[0].CostumeID;
                //    isBarCode = true;
                //}

                //BarCode4Costume costume = CommonGlobalUtil.GetBarCode(costumeID);
                //if (costume != null)
                //{
                //    costumeID = costume.CostumeID;
                //    isBarCode = true;
                //}

                List <CostumeItem> resultList = null;
                try
                {
                    //  this.ReadOnly = true;
                    resultList = CommonGlobalCache.ServerProxy.GetCostumeStoreList(
                        new CostumeStoreListPara()
                    {
                        CostumeID       = costumeID,
                        ShopID          = this.ShopID,
                        IsOnlyShowValid = filterValid
                    });
                }
                catch (Exception ex)
                {
                    CommonGlobalUtil.ShowError(ex);
                }
                finally
                {
                    //  this.ReadOnly = false;
                }

                //有供应商则过滤供应商
                if (SupplierID != null && resultList != null)
                {
                    resultList = resultList.FindAll(i => i.Costume.SupplierID == SupplierID);
                }
                if (resultList == null || resultList.Count == 0)
                {
                    if (this.CostumeSelected != null)
                    {
                        curItem = null;
                        this.CostumeSelected(curItem, false);
                    }
                    return;
                }
                else
                {
                    if (reload)
                    {
                        resultList = resultList.FindAll(t => t.Costume.ID.ToUpper() == costumeID.ToUpper());
                    }
                }

                if (resultList.Count == 1)
                {
                    resultList[0].Costume.BrandName    = CommonGlobalCache.GetBrandName(resultList[0].Costume.BrandID);
                    resultList[0].Costume.SupplierName = CommonGlobalCache.GetSupplierName(resultList[0].Costume.SupplierID);
                    if (resultList[0].CostumeStoreList != null)
                    {
                        foreach (var item in resultList[0].CostumeStoreList)
                        {
                            item.CostumeName = resultList[0].Costume.Name;
                            item.BrandName   = resultList[0].Costume.BrandName;
                            item.Price       = resultList[0].Costume.Price;
                            item.CostPrice   = resultList[0].Costume.CostPrice;
                        }
                    }

                    if (this.CostumeSelected != null)
                    {
                        curItem = resultList[0];
                        if (reload)
                        {
                            this.CostumeSelected(curItem, true);
                        }
                        else
                        {
                            this.CostumeSelected(curItem, false);
                        }
                    }
                }
            }
            // }
        }
예제 #13
0
        private static void setPrintPurchaseData(PurchaseOrder item, DataGridView dataGridView2, PrintTemplateType type)
        {
            InteractResult <PrintTemplateInfo> result = CommonGlobalCache.ServerProxy.GetPrintTemplateInfo(type);

            //行列数基本不受限制,但超过一页失去意义,因为以Body为主,以其它为辅
            //   Header header = new Header(4, 2);
            //可以指定每页是否重复打印
            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));

                    if (CurrentPTemplate.OrderName != "")
                    {
                        //misGoldPrinter.Title = CurrentPTemplate.OrderName; //主标题(C#用\n表示换行)

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

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



                        //header.IsDrawAllPage = true;

                        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);
                        CommonGlobalUtil.WriteLog("变量总数=" + CurrentPTemplate.SystemVariables.Count + "\r\n" + "应显示行号=" + headRow);
                        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 + item.CreateTime.GetDateTimeFormats('f')[0].ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "供应商")
                            {
                                KeyStr = "供 应 商:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetSupplierName(item.SupplierID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "操作人")
                            {
                                KeyStr = "操 作 人:";
                                header.SetText(curR, i % 2, KeyStr + CommonGlobalCache.GetUserName(item.AdminUserID));
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "总数量")
                            {
                                KeyStr = "总 数 量:";
                                header.SetText(curR, i % 2, KeyStr + item.TotalCount.ToString());
                            }
                            else if (CurrentPTemplate.SystemVariables[i] == "总成本")
                            {
                                KeyStr = "总 成 本:";
                                header.SetText(curR, i % 2, KeyStr + item.TotalCost.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.CreateTime.GetDateTimeFormats('f')[0].ToString());  //DataSource可以是字符串、一维数组、二维数组、DataTable、WinDataGrid、WebDataGrid、ListView\ListView、
                         * header.SetText(1, 0, "供 应 商:" + CommonGlobalCache.GetSupplierName(item.SupplierID));
                         * header.SetText(1, 1, "操 作 人:" + CommonGlobalCache.GetUserName(item.AdminUserID));               //同仁们还可以根据实际应用对GridBase的DataSource进行扩展
                         * header.SetText(2, 0, "总 数 量:" + item.TotalCount.ToString());
                         * header.SetText(2, 1, "总 成 本:" + item.TotalCost.ToString());                //同仁们还可以根据实际应用对GridBase的DataSource进行扩展
                         * header.SetText(3, 0, "备    注:");
                         * header.SetText(3, 1, item.Remarks);*/
                        misGoldPrinter.Header = header;
                        //misGoldPrinter.RowsPerPage
                        //Bottom bottom = new Bottom();
                        // bottom.DrawPrinterMargins

                        /*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,50,50,50,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>();
                         * List<int> columnCount = new List<int>();
                         * List<DataGridViewColumn> columns = new List<DataGridViewColumn>();
                         * List<PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;
                         * foreach (DataGridViewColumn col in dataGridView2.Columns)
                         * {
                         *  if (col.Tag?.ToString() != PrinterNoCount)
                         *  {
                         *      //  columns.Add(col);
                         *  }
                         *  if (dataGV.FindAll(t => t.Name == col.HeaderText).Count > 0)
                         *  {
                         *      columns.Add(col);
                         *
                         *  }
                         *    else
                         *    {
                         *      col.Visible = false;
                         *    }
                         *
                         *
                         *
                         * }
                         *
                         * for (int i = 0; i < columns.Count; i++)
                         * {
                         *  DataGridViewColumn column = columns[i];
                         *  if (column.Visible)
                         *  {
                         *      widthList.Add(widths[i]);
                         *  }
                         * }
                         *
                         * 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] * 10 * (decimal)0.1), 0, MidpointRounding.AwayFromZero));
                         * }
                         * ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth = widths;
                         * misGoldPrinter.Preview();
                         * misGoldPrinter.Dispose();
                         * misGoldPrinter = null;*/
                        List <PrintColumnInfo> dataGV = CurrentPTemplate.PrintColumnInfos;
                        string ColumnsList            = string.Empty;
                        foreach (PrintColumnInfo itemC in dataGV)
                        {
                            ColumnsList += itemC.Name + ",";
                        }
                        CommonGlobalUtil.WriteLog("模板设置打印列表头为=" + ColumnsList + "\r\n");
                        bool isflag = false;
                        if (dataGV.Count == 0)
                        {
                            isflag = true;
                        }

                        List <int> columnCount         = new List <int>();
                        int        pinrtColNum         = 0;
                        string     dataGridColumnsList = string.Empty;
                        if (dataGridView2.Columns.Count > 0)
                        {
                            for (int i = 0; i < dataGridView2.Columns.Count; i++)
                            {
                                DataGridViewColumn column = dataGridView2.Columns[i];
                                //if (column.HeaderText == "F" || column.HeaderText == "XS" || column.HeaderText == "S" || column.HeaderText == "M" || column.HeaderText == "L"
                                //   || column.HeaderText == "XL" || column.HeaderText == "2XL" || column.HeaderText == "3XL" || column.HeaderText == "4XL" || column.HeaderText == "5XL"
                                //   || column.HeaderText == "6XL")
                                //{
                                //    if (dataGV.FindAll(t => t.Name == "尺码列").Count > 0)
                                //    {
                                //        columnCount.Add(i);
                                //    }
                                //    else
                                //    {
                                //        column.Visible = false;
                                //    }
                                //}
                                //else
                                //{
                                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)
                                    {
                                        //打印设置模板不设置任何列,但由于MisGoldPrinter这个类的打印主体为DataGridView,所有必须设置一列默认空的
                                        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);
                            // misGoldPrinter.DataSource =   dataGridView2.DataSource;


                            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];
                             * }*/
                            //if (dataGridView2.Columns.Count > 0)
                            //{
                            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());
                            //misGoldPrinter.Bottom=
                            ((GoldPrinter.Body)(misGoldPrinter.Body)).ColsWidth = widths;
                            misGoldPrinter.Preview();
                            misGoldPrinter.Dispose();
                            //misGoldPrinter.Print();
                            misGoldPrinter = null;
                        }
                    }
                }
            }
        }