/// <summary>
        /// 修改明细
        /// </summary>
        /// <param name="quarantineList">产品明细对象</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>成功返回true</returns>
        public bool UpdateList(S_QuarantineList quarantineList, out string error)
        {
            error = "";

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var update = from a in dataContxt.S_QuarantineList
                             where a.Bill_ID == quarantineList.Bill_ID && a.ProductStockCode == quarantineList.ProductStockCode &&
                             a.GoodID == quarantineList.GoodID
                             select a;

                if (update.Count() > 0)
                {
                    S_QuarantineList quarantine = update.Single();

                    quarantine.IsHandle = true;

                    dataContxt.SubmitChanges();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        private void 质管toolScripButton_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked || rdbRepair.Checked)
            {
                if (rdbRepair.Checked)
                {
                    if (txtDispose.Text.Trim() == "")
                    {
                        MessageDialog.ShowPromptMessage("请填写处理方案!");
                        return;
                    }

                    m_blIsHandle = m_serverQuarantine.HandleBill(txtBill_ID.Text, txtDisposeName.Text, txtDispose.Text, out m_strErr);

                    if (m_blIsHandle)
                    {
                        DataTable dt = (DataTable)this.dgv_Main.DataSource;

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            S_QuarantineList list = new S_QuarantineList();

                            list.Bill_ID          = txtBill_ID.Text;
                            list.ProductStockCode = dt.Rows[i]["ProductCode"].ToString();
                            list.GoodID           = int.Parse(dt.Rows[i]["GoodsID"].ToString());

                            m_blIsHandle = m_serverQuarantine.UpdateList(list, out m_strErr);

                            if (m_blIsHandle)
                            {
                                m_blIsHandle = m_serverQuarantine.AuditingBill(txtBill_ID.Text, "全部处理", "已处理", out m_strErr);
                            }
                        }

                        if (m_blIsHandle)
                        {
                            MessageDialog.ShowPromptMessage("质管处理完成!");
                        }
                    }
                    else
                    {
                        MessageDialog.ShowPromptMessage(m_strErr);
                    }
                }
                else if (radioButton1.Checked)
                {
                    m_blIsHandle = m_serverQuarantine.AuditingBill(txtBill_ID.Text, "未完成", "已处理", out m_strErr);
                    MessageDialog.ShowPromptMessage("质管处理完成!");
                }
            }
            else
            {
                MessageDialog.ShowPromptMessage("请选择判定结果!");
                return;
            }

            this.Close();
        }
        private void dgv_Main_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row = dgv_Main.CurrentRow;

            txtGoodName.Text  = row.Cells["GoodsName"].Value.ToString();
            txtBatchNo.Text   = row.Cells["ProductCode"].Value.ToString();
            txtSpce.Text      = row.Cells["Spec"].Value.ToString();
            txtGoodsCode.Text = row.Cells["GoodsCode"].Value.ToString();
            txtType.Text      = row.Cells["Depot"].Value.ToString();
            txtUnitPrice.Text = row.Cells["UnitPrice"].Value.ToString();
            txtRemark.Text    = row.Cells["Remark"].Value.ToString();
            cmbStorage.Text   = row.Cells["Storage"].Value.ToString();
            txtGoodName.Tag   = Convert.ToInt32(row.Cells["GoodsID"].Value);

            if (e.RowIndex >= 0)
            {
                S_QuarantineList list = new S_QuarantineList();

                list.Bill_ID          = txtBill_ID.Text;
                list.ProductStockCode = dgv_Main.Rows[e.RowIndex].Cells["ProductCode"].Value.ToString();
                list.GoodID           = int.Parse(dgv_Main.Rows[e.RowIndex].Cells["GoodsID"].Value.ToString());

                DataTable dt = m_serverQuarantine.GetOperationStatus(txtBill_ID.Text, list.ProductStockCode, out m_strErr);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["IsHandle"].ToString().Equals("False"))
                    {
                        if (e.ColumnIndex == 11)
                        {
                            if (Convert.ToBoolean(dgv_Main.CurrentRow.Cells["选"].Value))
                            {
                                dgv_Main.CurrentRow.Cells["选"].Value = false;
                            }
                            else
                            {
                                dgv_Main.CurrentRow.Cells["选"].Value = true;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// 单据明细的数据库操作
        /// </summary>
        /// <param name="listInfo">需要操作的数据集</param>
        /// <param name="billID">单据号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>成功返回true</returns>
        public bool AddList(DataTable listInfo, string billID, out string error)
        {
            error = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            if (DeleteSellInList(billID, out error))
            {
                try
                {
                    for (int i = 0; i < listInfo.Rows.Count; i++)
                    {
                        S_QuarantineList lnqList = new S_QuarantineList();

                        lnqList.Bill_ID          = billID;
                        lnqList.GoodID           = int.Parse(listInfo.Rows[i]["GoodsID"].ToString());
                        lnqList.ProductStockCode = listInfo.Rows[i]["ProductCode"].ToString();
                        lnqList.BatchCode        = listInfo.Rows[i]["BatchNo"].ToString();
                        lnqList.Price            = decimal.Parse(listInfo.Rows[i]["UnitPrice"].ToString());
                        lnqList.Remark           = listInfo.Rows[i]["Remark"].ToString();
                        lnqList.Storage          = listInfo.Rows[i]["Storage"].ToString();
                        lnqList.IsHandle         = Convert.ToBoolean("False");

                        dataContxt.S_QuarantineList.InsertOnSubmit(lnqList);
                        //现在TABLE的数据的状态
                        UpdateProductStockStatus(listInfo.Rows[i]["ProductCode"].ToString(),
                                                 listInfo.Rows[i]["GoodsID"].ToString(), false, out error);
                    }

                    dataContxt.SubmitChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 仓管解封
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAffirm_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)this.dgv_Main.DataSource;

            if (m_strBillStatus != "已处理")
            {
                MessageDialog.ShowPromptMessage("请等待质管处理后,再进行此操作!");
                return;
            }

            if (dt.Rows.Count > 0)
            {
                int num = 0;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (Convert.ToBoolean(dt.Rows[i]["IsHandle"].ToString()))
                    {
                        num = 1;
                    }

                    DataTable dtList = m_serverQuarantine.GetOperationStatus(txtBill_ID.Text, dt.Rows[i]["ProductCode"].ToString(), out m_strErr);

                    if (!Convert.ToBoolean(dtList.Rows[0]["IsHandle"].ToString()) && Convert.ToBoolean(dt.Rows[i]["IsHandle"].ToString()))
                    {
                        S_QuarantineList list = new S_QuarantineList();

                        list.Bill_ID          = txtBill_ID.Text;
                        list.ProductStockCode = dt.Rows[i]["ProductCode"].ToString();
                        list.GoodID           = int.Parse(dt.Rows[i]["GoodsID"].ToString());

                        m_blIsHandle = m_serverQuarantine.UpdateList(list, out m_strErr);

                        if (m_blIsHandle)
                        {
                            m_blIsHandle = m_serverQuarantine.UpdateProductStockStatus(
                                dt.Rows[i]["ProductCode"].ToString(), dt.Rows[i]["GoodsID"].ToString(), true, out m_strErr);
                        }
                    }
                }
                if (num == 0)
                {
                    MessageDialog.ShowPromptMessage("请勾选需要解封的数据!");
                    return;
                }

                if (m_blIsHandle)
                {
                    string str    = "";
                    string status = "";

                    DataTable dtHandle = m_serverQuarantine.GetOperationStatus(txtBill_ID.Text, null, out m_strErr);

                    for (int i = 0; i < dtHandle.Rows.Count; i++)
                    {
                        if (dtHandle.Rows[i]["isHandle"].ToString() == "False")
                        {
                            str    = "未完成";
                            status = "已处理";
                            break;
                        }
                        else
                        {
                            str    = "全部处理";
                            status = "已解封";
                        }
                    }

                    m_blIsHandle = m_serverQuarantine.AuditingBill(txtBill_ID.Text, str, status, out m_strErr);

                    if (m_blIsHandle)
                    {
                        MessageDialog.ShowPromptMessage("解封成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(m_strErr);
                        return;
                    }
                }
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            string    Bill_ID = "";
            DataTable dt      = (DataTable)this.dataGridView1.DataSource;

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow drStockCode = m_serverQuarantine.GetBillID(dt.Rows[i]["箱体编号"].ToString());
                    Bill_ID = drStockCode[0].ToString();
                    DataTable dtList = m_serverQuarantine.GetOperationStatus(Bill_ID, dt.Rows[i]["箱体编号"].ToString(), out m_strErr);

                    if (!Convert.ToBoolean(dtList.Rows[0]["IsHandle"].ToString()))
                    {
                        S_QuarantineList list = new S_QuarantineList();

                        list.Bill_ID          = Bill_ID;
                        list.ProductStockCode = dt.Rows[i]["箱体编号"].ToString();
                        list.GoodID           = int.Parse(dt.Rows[i]["GoodsID"].ToString());

                        m_blIsHandle = m_serverQuarantine.UpdateList(list, out m_strErr);

                        if (m_blIsHandle)
                        {
                            m_blIsHandle = m_serverQuarantine.UpdateProductStockStatus(
                                dt.Rows[i]["箱体编号"].ToString(), dt.Rows[i]["GoodsID"].ToString(), true, out m_strErr);
                        }
                    }
                }

                if (m_blIsHandle)
                {
                    string    str      = "";
                    DataTable dtHandle = m_serverQuarantine.GetOperationStatus(Bill_ID, null, out m_strErr);

                    for (int i = 0; i < dtHandle.Rows.Count; i++)
                    {
                        string str2 = dtHandle.Rows[i]["isHandle"].ToString();

                        if (dtHandle.Rows[i]["isHandle"].ToString() == "False")
                        {
                            str = "未完成";
                            break;
                        }
                        else
                        {
                            str = "全部处理";
                        }
                    }

                    m_blIsHandle = m_serverQuarantine.AuditingBill(Bill_ID, str, "已解封", out m_strErr);

                    if (m_blIsHandle)
                    {
                        MessageDialog.ShowPromptMessage("解封成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(m_strErr);
                        return;
                    }
                }
            }
        }