/// <summary>
        /// 新增一条记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneQCRecord(WeighStrategyRecord qcRecord)
        {
            bool rbool = true;

            using (DCCarManagementDataContext db = new DCCarManagementDataContext())
            {
                try
                {
                    rbool = LinQBaseDao.InsertOne(db, qcRecord);
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
        /// <summary>
        /// 保存地磅房过磅重量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string iccard_id    = txtSerialnumber.Text.Trim();
                string txtinweight  = txtInWeight.Text.ToString().Trim();
                string txtoutweight = txtOutWeight.Text.ToString().Trim();
                strsql();
                if (sql == "")
                {
                    MessageBox.Show("没有该IC卡(小票)号的信息!");
                    return;
                }
                DataTable table = LinQBaseDao.Query(sql).Tables[0];
                if (table.Rows.Count > 0)
                {
                    if (Convert.ToBoolean(table.Rows[0]["CarInOutRecord_ISFulfill"].ToString()))
                    {
                        MessageBox.Show("该车辆通行已完成!");
                        return;
                    }
                    if (ISFill(table) == false)
                    {
                        return;
                    }
                    string    carinoutrecord = table.Rows[0]["CarInOutRecord_ID"].ToString();
                    string    weight1        = "";
                    string    weight2        = "";
                    string    type           = "";
                    DataTable tableB         = LinQBaseDao.Query("select * from BusinessRecord where BusinessRecord_CarInOutRecord_ID=" + carinoutrecord).Tables[0];
                    for (int i = 0; i < tableB.Rows.Count; i++)
                    {
                        if (tableB.Rows[i]["BusinessRecord_Type"].ToString() == CommonalityEntity.upWeight)
                        {
                            weight1 = tableB.Rows[i]["BusinessRecord_Weight"].ToString();
                        }
                        if (tableB.Rows[i]["BusinessRecord_Type"].ToString() == CommonalityEntity.outWeight)
                        {
                            weight2 = tableB.Rows[i]["BusinessRecord_Weight"].ToString();
                        }
                        if (tableB.Rows[i]["BusinessRecord_Type"].ToString() == CommonalityEntity.loadSecondWeight || tableB.Rows[i]["BusinessRecord_Type"].ToString() == CommonalityEntity.unloadSecondWeight)
                        {
                            type = tableB.Rows[i]["BusinessRecord_Type"].ToString();
                        }
                    }
                    //对地磅策略判断   该磅房信息
                    if (Convert.ToInt32(cobWeighStrategyRecord.SelectedValue) < 1)
                    {
                        MessageBox.Show("请选择此磅房名称");
                        return;
                    }
                    if (!WeighStrategyIf())
                    {
                        return;
                    }
                    //判断进门地磅是否重复记录,如果原记录重量不等于现在输入的重量则提示是否修改
                    if (txtinweight != "" && weight1 != txtinweight)
                    {
                        DataTable dtbus = LinQBaseDao.Query("select * from BusinessRecord where BusinessRecord_Type='" + CommonalityEntity.upWeight + "' and BusinessRecord_CarInOutRecord_ID=" + carinoutrecord).Tables[0];
                        if (dtbus.Rows.Count > 0)
                        {
                            if (MessageBox.Show("是否修改进门地磅重量?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                LinQBaseDao.Query(" update BusinessRecord set BusinessRecord_Weight=" + txtinweight + " where BusinessRecord_CarInOutRecord_ID=" + carinoutrecord + " and BusinessRecord_Type='" + CommonalityEntity.upWeight + "'");
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            string content = table.Rows[0]["CarInfo_PO"].ToString();
                            save(carinoutrecord, content, CommonalityEntity.upWeight, txtinweight);

                            MessageBox.Show("保存成功!");
                            CommonalityEntity.strCardNo = "";
                            CommonalityEntity.WriteLogData("记录", "记录IC卡(小票)号为:" + txtSerialnumber.Text.Trim() + "的进门过磅信息", CommonalityEntity.USERNAME);//添加操作日志

                            //记录地磅策略已通过
                            record = new WeighStrategyRecord();//txtCarregistration_Carnumber
                            record.WeighStrategyRecord_WeighInfo_ID   = Convert.ToInt32(cobWeighStrategyRecord.SelectedValue);
                            record.WeighStrategyRecord_StaffInfo_ID   = Convert.ToInt32(txtCarregistration_Name.Tag.ToString());
                            record.WeighStrategyRecord_CarInfo_ID     = Convert.ToInt32(txtCarregistration_Carnumber.Tag.ToString());
                            record.WeighStrategyRecord_Carnumber      = txtCarregistration_Carnumber.Text.Trim();
                            record.WeighStrategyRecord_StaffInfo_Name = txtCarregistration_Name.Text.Trim();
                            record.WeighStrategyRecord_CarType        = txtCartype_Name.Text.Trim();
                            record.WeighStrategyRecord_mark           = true;
                            record.WeighStrategyRecord_RecordTime     = CommonalityEntity.GetServersTime();
                            record.WeighStrategyRecord_Name           = cobWeighStrategyRecord.Text.Trim();
                            record.WeighStrategyRecord_order          = RraderSort;
                            record.WeighStrategyRecord_Remark         = txtRemark.Text.Trim();
                            if (!WeighStrategyRecordDAL.InsertOneQCRecord(record))
                            {
                                // MessageBox.Show("地磅房策略通行记录失败!");
                            }
                        }
                    }
                    //判断出门地磅是否重复记录,如果原记录重量不等于现在输入的重量则提示是否修改
                    if (txtoutweight != "" && weight2 != txtoutweight)
                    {
                        DataTable ds = LinQBaseDao.Query("select * from BusinessRecord where BusinessRecord_Type='" + CommonalityEntity.outWeight + "' and BusinessRecord_CarInOutRecord_ID=" + carinoutrecord + " order by BusinessRecord_ID desc").Tables[0];
                        if (ds.Rows.Count > 0)
                        {
                            if (MessageBox.Show("是否修改出门地磅重量?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                LinQBaseDao.Query(" update BusinessRecord set BusinessRecord_Weight=" + txtoutweight + " where BusinessRecord_CarInOutRecord_ID=" + carinoutrecord + " and BusinessRecord_Type='" + CommonalityEntity.outWeight + "'");
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            if (type == CommonalityEntity.loadSecondWeight || type == CommonalityEntity.unloadSecondWeight)
                            {
                                string carinfo_po = table.Rows[0]["CarInfo_PO"].ToString();
                                save(carinoutrecord, carinfo_po, CommonalityEntity.outWeight, txtoutweight);
                                MessageBox.Show("保存成功!");
                                CommonalityEntity.strCardNo = "";
                                CommonalityEntity.WriteLogData("记录", "记录IC卡(小票)号为:" + txtSerialnumber.Text.Trim() + "的" + CommonalityEntity.outWeight + "信息", CommonalityEntity.USERNAME);//添加操作日志

                                //记录地磅策略已通过
                                record = new WeighStrategyRecord();
                                record.WeighStrategyRecord_WeighInfo_ID   = Convert.ToInt32(cobWeighStrategyRecord.SelectedValue);
                                record.WeighStrategyRecord_StaffInfo_ID   = Convert.ToInt32(txtCarregistration_Name.Tag.ToString());
                                record.WeighStrategyRecord_CarInfo_ID     = Convert.ToInt32(txtCarregistration_Carnumber.Tag.ToString());
                                record.WeighStrategyRecord_Carnumber      = txtCarregistration_Carnumber.Text.Trim();
                                record.WeighStrategyRecord_StaffInfo_Name = txtCarregistration_Name.Text.Trim();
                                record.WeighStrategyRecord_CarType        = txtCartype_Name.Text.Trim();
                                record.WeighStrategyRecord_mark           = true;
                                record.WeighStrategyRecord_RecordTime     = CommonalityEntity.GetServersTime();
                                record.WeighStrategyRecord_Name           = cobWeighStrategyRecord.Text.Trim();
                                record.WeighStrategyRecord_order          = RraderSort;
                                record.WeighStrategyRecord_Remark         = txtRemark.Text.Trim();
                                if (!WeighStrategyRecordDAL.InsertOneQCRecord(record))
                                {
                                    //MessageBox.Show("地磅房策略通行记录失败!");
                                }
                            }
                            else
                            {
                                MessageBox.Show("没有装卸货点第二次过磅重量");
                                txtOutWeight.Text = "";
                                return;
                            }
                        }
                    }
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("地磅房信息 btnSave_Click()");
            }
        }