/// <summary>
        /// 导入库存管理开单方法
        /// </summary>
        /// <param name="BillTable">开单表</param>
        /// <param name="PartTable">配件表</param>
        /// <param name="BillingPrimID">开单主键ID名称</param>
        /// <param name="QueryLogMsg">数据库查询日志</param>
        /// <param name="ModifyLogMsg">数据库修改日志</param>
        private void ImportStockBillMethod(string BillTable, string PartTable, string BillingPrimID, string QueryLogMsg, string ModifyLogMsg, string BillType)
        {
            try
            {
                UCImportStockBill UCPSB = null;
                if (Combbilling_type_name.Text.ToString() == AllotBill)
                {//调拨单导入
                    UCPSB = new UCImportStockBill(Comborder_type_name.Text.ToString(), Combbilling_type_name.Text.ToString(), Combwh_name.Text.ToString());
                }
                else
                {//非调拨单导入
                    UCPSB = new UCImportStockBill(Comborder_type_name.Text.ToString(), Combbilling_type_name.Text.ToString());
                }
                DialogResult result = UCPSB.ShowDialog();

                if (result == DialogResult.OK)
                {
                    sb_Fields.Clear();//清空所有字符串
                    //sb_Fields.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                    //BillingPrimID, PartCode, PartsName, PartModel, DrawNum, UnitName, PartsBrand, BusinCount, Remark);//要查询的字段名称格式项
                    DataTable dt_Parts = null;//配件信息数据表 
                    string BillPrimIDValue = string.Empty;//要查询的开单主键ID条件
                    string PartNumber = string.Empty;//查询的配件编号条件
                    string BillTypeName = Combbilling_type_name.Text.ToString();//开单类型名
                    BillingIDLst = UCPSB.StockBillIDLst;//获取导入开单主键ID
                    if (BillTypeName == AllotBill) sb_Fields.Append(UCPSB.AllotFields + "," + PartsBrand + "," + Remark);//调拨单配件
                    else if (BillTypeName == OtherReceiveBill || BillTypeName == OtherSendBill) sb_Fields.Append(UCPSB.ReceiveShipFields
                    + "," + PartModel + "," + PartsBrand + "," + Remark);//其它收发货单配件
                    else if (BillTypeName == MaterialRequisition) sb_Fields.Append(UCPSB.FetchRefundFields + ",norms,remarks");//领料单配件
                    else if (BillTypeName == RefundBill) sb_Fields.Append(UCPSB.FetchRefundFields + ",norms,remarks");//领料退货单配件
                    else if (BillTypeName == InventoryBill) sb_Fields.Append(UCPSB.InventoryFields+","+PartsBrand+","+Remark);//盘点单配件
                    foreach (string item in UCPSB.StockBillIDLst)
                    {
                        BillPrimIDValue = item.ToString();//要查询的条件
                        if (gvPartsMsgList.Rows.Count > 0)
                        {

                            for (int i = 0; i < gvPartsMsgList.Rows.Count; i++)
                            {
                                //判断要导入开单信息是否已存在于列表中
                                string BPrimID = gvPartsMsgList.Rows[i].Cells["billing_ID"].Value.ToString();//开单主键ID
                                if (item.ToString() == BPrimID)
                                {
                                    MessageBoxEx.Show("您要导入的" + BillTypeName + "已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    return;
                                }
                                else
                                { 
                                    //查询符合条件的配件信息
                                    dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), BillingPrimID + "='" + BillPrimIDValue + "'", "", "");
                                }


                            }
                        }
                        else
                        {
                            dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), BillingPrimID + "='" + BillPrimIDValue + "'", "", "");
                        }
                      
                        GetGridViewRowByDrImport(dt_Parts, BillingPrimID, BillType);//把查询到的配件信息导入控件列表

                    }

                    //判断配件信息列表中的值是否需要导入
                    if (UCPSB.PartHTable.Count != 0)
                    {
                        foreach (DictionaryEntry DicEty in UCPSB.PartHTable)
                        {
                            PartNumber = DicEty.Key.ToString();//获取配件编码
                            BillPrimIDValue = DicEty.Value.ToString();//获取开单号
                            //对应单据的配件信息查询条件
                            string PartWhere =BillingPrimID+"='" + BillPrimIDValue + "'" + " and  parts_code='" + PartNumber + "'";
                            if (gvPartsMsgList.Rows.Count > 0)
                            {
                                for (int k = 0; k < gvPartsMsgList.Rows.Count; k++)
                                {
                                    string gvPartNumber = gvPartsMsgList.Rows[k].Cells["partsnum"].Value.ToString();//配件列表中的配件编号
                                    string gvBillId = gvPartsMsgList.Rows[k].Cells["billing_ID"].Value.ToString();//配件列表中隐藏的开单主键ID
                                    if (BillPrimIDValue == gvBillId && PartNumber == gvPartNumber)
                                    {
                                        MessageBoxEx.Show("您要导入的" + BillTypeName + "已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        return;
                                    }
                                    else
                                    {
                                        dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), PartWhere, "", "");
                                       
                                    }
                                }
                            }
                            else
                            {
                                dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), PartWhere, "", "");
                            }
                            GetGridViewRowByDrImport(dt_Parts, BillingPrimID, BillType);//导入配件信息列表

                        }
                                          
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
        /// <summary>
        /// 导入库存管理开单方法
        /// </summary>
        /// <param name="BillTable">开单表</param>
        /// <param name="PartTable">配件表</param>
        /// <param name="BillingPrimID">开单主键ID名称</param>
        /// <param name="QueryLogMsg">数据库查询日志</param>
        /// <param name="ModifyLogMsg">数据库修改日志</param>
        private void ImportStockBillMethod(string BillTable, string PartTable, string BillingPrimID, string QueryLogMsg, string ModifyLogMsg, string BillType)
        {
            try
            {
                UCImportStockBill UCPSB =  new UCImportStockBill(Comborder_type_name.Text.ToString(), Combbilling_type_name.Text.ToString());
                DialogResult result = UCPSB.ShowDialog();

                if (result == DialogResult.OK)
                {
                    sb_Fields.Clear();//清空所有字符串
                    DataTable dt_Parts = null;//配件信息数据表 
                    string BillPrimIDValue = string.Empty;//要查询的开单主键ID条件
                    string BillNo = string.Empty;//开单编号
                    string PartNumber = string.Empty;//查询的配件编号条件
                    string BillTypeName = Combbilling_type_name.Text.ToString();//开单类型名
                    BillingIDLst =new List<string>( UCPSB.StockBillIDDic.Keys);//获取导入开单主键ID
                    if (Comborder_type_name.Text.ToString() == storage && BillTypeName == AllotBill) sb_Fields.Append(UCPSB.AllotFields + ","
                    + CallInWhouseId + "," + CarPCode + "," + BarCode + "," + CallInWhouseName + "," + PartsBrand + "," + Remark);//调拨入库单配件
                    else if (Comborder_type_name.Text.ToString() == OutBound && BillTypeName == AllotBill) sb_Fields.Append(UCPSB.AllotFields + ","
                      + CallOutWhouseId + "," + CarPCode + "," + BarCode + "," + CallOutWhouseName + "," + PartsBrand + "," + Remark);//调拨出库单配件
                    else if (BillTypeName == OtherReceiveBill || BillTypeName == OtherSendBill) sb_Fields.Append(UCPSB.ReceiveShipFields
                    + "," + WhouseId + "," + WhouseName + "," + PartModel + "," + CarPCode + "," + BarCode + "," + PartsBrand + "," + Remark);//其它收发货单配件
                    else if (BillTypeName == MaterialRequisition) sb_Fields.Append(UCPSB.FetchRefundFields + ",warehouse,wh_name,norms,remarks");//领料单配件
                    else if (BillTypeName == RefundBill) sb_Fields.Append(UCPSB.FetchRefundFields + ",warehouse,wh_name,norms,remarks");//领料退货单配件
                    else if (BillTypeName == InventoryBill) sb_Fields.Append(UCPSB.InventoryFields + "," + CarPCode + "," + BarCode + "," + PartsBrand + "," + Remark);//盘点单配件
                    foreach (KeyValuePair<string,string> KVPair in UCPSB.StockBillIDDic)
                    {
                        BillPrimIDValue = KVPair.Key.ToString();//要查询的条件
                        BillNo = KVPair.Value.ToString();//获取开单编号
                        if (gvPartsMsgList.Rows.Count > 0)
                        {

                            for (int i = 0; i < gvPartsMsgList.Rows.Count; i++)
                            {
                                //判断要导入开单信息是否已存在于列表中
                                string BPrimID = gvPartsMsgList.Rows[i].Cells["billing_ID"].Value.ToString();//开单主键ID
                                if (KVPair.ToString() == BPrimID)
                                {
                                    MessageBoxEx.Show("您要导入的" + BillTypeName + "已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    return;
                                }
                                else
                                {
                                    if (BillTypeName == MaterialRequisition || BillTypeName == RefundBill)
                                    {
                                        //查询符合条件的配件信息
                                        dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable+" left join "+WareHouseTable+" on "+WareHouseTable+"."+
                                        WhouseId + "=" + PartTable+"."+WhouseId, 
                                        sb_Fields.ToString(), BillingPrimID + "='" + BillPrimIDValue + "'", "", "");
                                    }
                                    else
                                    {
                                        //查询符合条件的配件信息
                                        dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), BillingPrimID + "='" + BillPrimIDValue + "'", "", "");
                                    }
                                }


                            }
                        }
                        else
                        {
                            dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), BillingPrimID + "='" + BillPrimIDValue + "'", "", "");
                        }

                        GetGridViewRowByDrImport(dt_Parts, BillingPrimID, BillNo,BillType);//把查询到的配件信息导入控件列表

                    }

                    //判断配件信息列表中的值是否需要导入
                    if (UCPSB.PartHTable.Count != 0)
                    {
                        foreach (DictionaryEntry DicEty in UCPSB.PartHTable)
                        {
                            PartNumber = DicEty.Key.ToString();//获取配件编码
                            BillPrimIDValue = DicEty.Value.ToString();//获取开单号
                            //对应单据的配件信息查询条件
                            string PartWhere =BillingPrimID+"='" + BillPrimIDValue + "'" + " and  parts_code='" + PartNumber + "'";
                            if (gvPartsMsgList.Rows.Count > 0)
                            {
                                for (int k = 0; k < gvPartsMsgList.Rows.Count; k++)
                                {
                                    string gvPartNumber = gvPartsMsgList.Rows[k].Cells["partsnum"].Value.ToString();//配件列表中的配件编号
                                    string gvBillId = gvPartsMsgList.Rows[k].Cells["billing_ID"].Value.ToString();//配件列表中隐藏的开单主键ID
                                    if (BillPrimIDValue == gvBillId && PartNumber == gvPartNumber)
                                    {
                                        MessageBoxEx.Show("您要导入的" + BillTypeName + "已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        return;
                                    }
                                    else
                                    {
                                        dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), PartWhere, "", "");
                                       
                                    }
                                }
                            }
                            else
                            {
                                dt_Parts = DBHelper.GetTable(QueryLogMsg, PartTable, sb_Fields.ToString(), PartWhere, "", "");
                            }
                            GetGridViewRowByDrImport(dt_Parts, BillingPrimID, BillNo, BillType);//导入配件信息列表

                        }
                                          
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }