private void dgvExAllocation_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex > -1)
     {
         using (申请费用分配 mForm = new 申请费用分配())
         {
             mForm.mRow = dgvExAllocation.Rows[e.RowIndex];
             mForm.ExId = Convert.ToInt64(dgvExAllocation.Rows[e.RowIndex].Cells["idDataGridViewTextBoxColumn"].Value);
             mForm.ShowDialog();
         }
     }
 }
        private void dgvSaleDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == dgvSaleDetails.Columns["ColModify"].Index && Classes.PubClass.UserStatus == "正常")
                {
                    if (dgvSaleDetails.Rows[e.RowIndex].Cells["expenseStatus"].Value.ToString() == "领导审核通过")
                    {
                        MessageBox.Show("领导审核通过的订单不能修改");
                        return;
                    }
                    销售明细维护 mForm = new 销售明细维护();
                    mForm.mId = Convert.ToInt64(dgvSaleDetails.Rows[e.RowIndex].Cells["idDataGridViewTextBoxColumn"].Value);
                    mForm.ShowDialog();
                }
                if (e.ColumnIndex == dgvSaleDetails.Columns["TableNo"].Index && Classes.PubClass.UserStatus == "正常")
                {
                    if (dgvSaleDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString() == "申请费用分配")
                    {
                        using (申请费用分配 mForm = new 申请费用分配())
                        {
                            mForm.mRow = dgvSaleDetails.Rows[e.RowIndex];
                            if (mForm.ShowDialog() == DialogResult.OK)
                            {
                                int mIndex = dgvSaleDetails.FirstDisplayedScrollingRowIndex; //记录当前第一行
                                btnSerch_Click(sender, e);
                                dgvSaleDetails.FirstDisplayedScrollingRowIndex = mIndex;     //还原当前第一行
                            }
                        }
                    }
                    else
                    {
                        //MessageBox.Show(dgvSaleDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString());
                        using (申请费用分配 mForm = new 申请费用分配())
                        {
                            mForm.isModify = true;
                            mForm.mRow     = dgvSaleDetails.Rows[e.RowIndex];
                            mForm.ExId     = Convert.ToInt64(dgvSaleDetails.Rows[e.RowIndex].Cells["ExpenseAllocation"].Value);

                            if (mForm.ShowDialog() == DialogResult.OK)
                            {
                                btnSerch_Click(sender, e);
                            }

                            //  mForm.ShowDialog();
                        }
                    }
                }
                if (e.ColumnIndex == dgvSaleDetails.Columns["ColPrint"].Index && Classes.PubClass.UserStatus == "正常")
                {
                    string mCompanyName = "651984618945316891318";
                    int    mCount       = 0;
                    foreach (DataGridViewRow mRow in dgvSaleDetails.Rows)
                    {
                        if (Convert.ToBoolean(mRow.Cells["ColPrint"].Value) == true)
                        {
                            mCompanyName = mRow.Cells["customerNameDataGridViewTextBoxColumn"].Value.ToString();
                            mCount++;
                        }
                    }
                    if (mCount >= 20)
                    {
                        MessageBox.Show("选中的个数不能超过20个");
                        return;
                    }
                    if (mCompanyName != "651984618945316891318" && Convert.ToString(dgvSaleDetails.Rows[e.RowIndex].Cells["customerNameDataGridViewTextBoxColumn"].Value) != mCompanyName)
                    {
                        DataGridViewCheckBoxCell mCell = dgvSaleDetails[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell;
                        mCell.EditingCellFormattedValue = false;
                        mCell.EditingCellValueChanged   = true;
                        mCell.Value = mCell.FormattedValue;
                        MessageBox.Show("与已选择的公司名称不一致");
                    }
                    else
                    {
                        DataGridViewCheckBoxCell mCell = dgvSaleDetails[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell;
                        mCell.EditingCellFormattedValue = bool.Parse(mCell.EditedFormattedValue.ToString());
                        mCell.EditingCellValueChanged   = true;
                        mCell.Value = mCell.FormattedValue;
                    }
                }
                //if (e.ColumnIndex == 2)
                //{
                //    if (dgvSaleDetails.Rows[e.RowIndex].Cells["operNameDataGridViewTextBoxColumn"].Value.ToString() == Classes.PubClass.LoginName)
                //    {
                //        if (MessageBox.Show("确认删除该客户资料?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
                //        {
                //            long mId = Convert.ToInt64(dgvSaleDetails.Rows[e.RowIndex].Cells[0].Value);
                //            int ret = new T_SaleDetailsTableAdapter().DeleteById(mId);
                //            if (ret > 0)
                //            {
                //                dgvSaleDetails.Rows.RemoveAt(e.RowIndex);
                //            }
                //            else
                //            {
                //                MessageBox.Show("删除失败");
                //            }

                //        }
                //    }

                //}
            }
        }