/// <summary>
        /// 打印预览及打印模版
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLEDShow_Click(object sender, EventArgs e)
        {
            //获取选择的打印设置行,得到选择的打印的预览信息
            try
            {
                if (this.lvwUserList.SelectedRows.Count <= 0)
                {
                    MessageBox.Show("请选择要预览的设置!");
                    return;
                }
                if (this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString() == "")
                {
                    MessageBox.Show("请选择要预览的设置!");
                    return;
                }
                else
                {
                    CommonalityEntity.Car_Type_ID = this.lvwUserList.SelectedRows[0].Cells["Print_CarType_Id"].Value.ToString();
                    string    sql        = "select * from PrintInfo where Print_ID='" + this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString() + "'";
                    PrintInfo pInfo      = PrintInfoDAL.GetPrint(sql);
                    DataSet   dataset    = new DataSet();
                    string    sqlContent = "Select top 1 ";
                    if (pInfo.Print_Content != "")
                    {
                        string[] str = pInfo.Print_Content.Split(',');
                        foreach (var item in str)
                        {
                            sqlContent += item + ",";
                        }
                        sqlContent = sqlContent.Substring(0, sqlContent.Length - 1);
                    }

                    string strsqlContent = sqlContent + " from View_LEDShow_zj where CarType_ID=" + CommonalityEntity.Car_Type_ID;
                    dataset = LinQBaseDao.Query(strsqlContent);
                    if (dataset.Tables[0].Rows.Count > 0)
                    {
                        CommonalityEntity.Serialnumber = dataset.Tables[0].Rows[0]["小票号"].ToString();
                        PrintInfoForm pi = new PrintInfoForm(dataset);
                        pi.Show();
                    }
                    else
                    {
                        strsqlContent = sqlContent + " from View_LEDShow_zj";
                        dataset       = LinQBaseDao.Query(strsqlContent);
                        CommonalityEntity.Serialnumber = "130808000001";
                        PrintInfoForm pi = new PrintInfoForm(dataset);
                        pi.Show();
                    }
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("PrintSetForm btnLEDShow_Click()");//记录异常日志
            }
        }
        private void lvwUserList_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (this.lvwUserList.SelectedRows.Count <= 0)
                {
                    MessageBox.Show("请选择要修改的项!");
                    return;
                }
                if (this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString() == "")
                {
                    MessageBox.Show("请选择要修改的项!");
                    return;
                }
                else
                {
                    string    sql   = "select * from PrintInfo where Print_ID='" + this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString() + "'";
                    PrintInfo pInfo = PrintInfoDAL.GetPrint(sql);
                    comboxCartype.SelectedValue = pInfo.Print_CarType_ID;
                    chkPrint_State.Text         = pInfo.Print_State;

                    //////////////////////////
                    txttisi.Text          = lvwUserList.SelectedRows[0].Cells["Print_Attention"].Value.ToString();
                    txtzhuyishixiang.Text = lvwUserList.SelectedRows[0].Cells["Print_Prompt"].Value.ToString();

                    string[] content = pInfo.Print_Content.Split(',');
                    foreach (var item in content)
                    {
                        if (item == chkCarNumber.Text)
                        {
                            chkCarNumber.Checked = true;
                        }
                        if (item == chkStaff_Name.Text)
                        {
                            chkStaff_Name.Checked = true;
                        }
                        if (item == chkCarType.Text)
                        {
                            chkCarType.Checked = true;
                        }
                    }
                    btnAdd.Enabled    = false;
                    btnUpdate.Enabled = true;
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("PrintSetForm lvwUserList_RowHeaderMouseDoubleClick()"); //记录异常日志
            }
        }
 /// <summary>
 /// 删除选中设置  启动状态不能删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.lvwUserList.SelectedRows.Count <= 0)
         {
             MessageBox.Show("请选择要删除的项!");
             return;
         }
         if (this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString() == "")
         {
             MessageBox.Show("请选择要删除的项!");
             return;
         }
         if (this.lvwUserList.SelectedRows[0].Cells["Print_State"].Value.ToString() == "启动")
         {
             MessageBox.Show("启用状态的打印设置不能删除!");
             return;
         }
         DialogResult dlgResult = MessageBox.Show("确定删除选中的数据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (dlgResult == DialogResult.Cancel)
         {
             return;
         }
         //删除条件
         int id = int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString());
         Expression <Func <PrintInfo, bool> > fun = n => n.Print_ID == id && n.Print_State != "启动";
         PrintInfoDAL.DeletePrintInfo(fun);
         CommonalityEntity.WriteLogData("删除", "删除编号为" + id + "的打印设置", CommonalityEntity.USERNAME);//添加操作日志
     }
     catch
     {
         CommonalityEntity.WriteTextLog("PrintSetForm btnDelete_Click()");
     }
     finally
     {
         GetGriddataviewLoad("");//加载
     }
 }
Example #4
0
 /// <summary>
 /// 记录打印记录
 /// </summary>
 private void AddPrintRecord()
 {
     try
     {
         string strsql = "   select SortNumberInfo_ID from SortNumberInfo where SortNumberInfo_SmallTicket_ID in (select SmallTicket_ID from SmallTicket where SmallTicket_CarInfo_ID='" + carinfoid + "') order by SortNumberInfo_ID desc ";
         prdObj = LinQBaseDao.GetSingle(strsql);
         //记录打印
         PrintRecord prd = new PrintRecord();
         prd.PrintRecord_Time    = CommonalityEntity.GetServersTime();
         prd.PrintRecord_Remark  = "";
         prd.PrintRecord_Operate = CommonalityEntity.USERNAME;
         if (!string.IsNullOrEmpty(prdObj.ToString()))
         {
             prd.PrintRecord_SortNumberInfo_ID = int.Parse(prdObj.ToString());
         }
         PrintInfoDAL.InsertPrint(prd);
         printPreviewDialog.Close();
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// 验证LED设置状态是否重复
        /// </summary>
        /// <returns></returns>
        public bool ChkPrintState()
        {
            bool chkState = false;

            try
            {
                string sql = "";
                if (isUpdate)
                {
                    sql = "Select * from PrintInfo where print_State='启动' and print_ID!=" + int.Parse(this.lvwUserList.SelectedRows[0].Cells["print_id"].Value.ToString()) + "  and print_carType_ID = " + int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_CarType_Id"].Value.ToString()) + "";
                }
                else
                {
                    sql = "Select * from PrintInfo where print_State='启动'  and print_carType_ID = " + comboxCartype.SelectedValue + "";
                }
                chkState = PrintInfoDAL.ChkPrintState(sql);
            }
            catch
            {
                CommonalityEntity.WriteTextLog("PrintSetForm ChkPositionLEDState()");
            }
            return(chkState);
        }
        /// <summary>
        /// 应用打印设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLEDApplication_Click(object sender, EventArgs e)
        {
            try
            {
                CommonalityEntity.IsCancellation = false;
                isUpdate = true;
                int id = int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString());
                if (ChkPrintState())
                {
                    DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dlgResult == DialogResult.OK)
                    {
                        //修改条件
                        Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_CarType_ID"].Value.ToString());
                        //需要修改的内容
                        Action <PrintInfo> actions = p =>
                        {
                            p.Print_State = "暂停";
                        };
                        //执行更新
                        PrintInfoDAL.UpdatePrint(funs, actions);

                        //应用当前选中的设置
                        //条件
                        Expression <Func <PrintInfo, bool> > fun = n => n.Print_ID == id;
                        //需要的内容
                        Action <PrintInfo> action = p =>
                        {
                            p.Print_State = "启动";
                        };
                        //执行更新
                        PrintInfoDAL.UpdatePrint(fun, action);
                        CommonalityEntity.WriteLogData("修改", "启动打印编号为:" + id + "的打印设置", CommonalityEntity.USERNAME);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    //应用当前选中的设置
                    //条件
                    Expression <Func <PrintInfo, bool> > fun = n => n.Print_ID == id;
                    //需要的内容
                    Action <PrintInfo> action = p =>
                    {
                        p.Print_State = "启动";
                    };
                    //执行更新
                    PrintInfoDAL.UpdatePrint(fun, action);
                    CommonalityEntity.WriteLogData("修改", "启动打印编号为:" + id + "的打印设置", CommonalityEntity.USERNAME);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("LEDSerForm btnLEDApplication_Click()");
            }
            finally
            {
                GetGriddataviewLoad("");//加载
            }
        }
 /// <summary>
 /// 保存设置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         //得到页面对应车辆类型的打印设置
         int carType_ID = int.Parse(comboxCartype.SelectedValue.ToString());
         //得到选择的打印内容
         string print_Content = "";
         if (chkCarNumber.Checked)
         {
             print_Content += chkCarNumber.Text.Trim() + ",";
         }
         if (chkCarType.Checked)
         {
             print_Content += chkCarType.Text.Trim() + ",";
         }
         if (chkStaff_Name.Checked)
         {
             print_Content += chkStaff_Name.Text.Trim() + ",";
         }
         if (chkList.CheckedItems.Count > 0)
         {
             foreach (var item in chkList.CheckedItems)
             {
                 print_Content += item + ",";
             }
         }
         PrintInfo print = new PrintInfo();
         print.Print_Content    = print_Content.Substring(0, print_Content.Length - 1);
         print.Print_CarType_ID = carType_ID;
         print.Print_State      = chkPrint_State.Text.Trim();
         print.Print_Attention  = txtzhuyishixiang.Text.Trim();
         print.Print_Prompt     = txttisi.Text.Trim();
         if (chkPrint_State.Text.Trim() == "启动")
         {
             if (ChkPrintState())
             {
                 DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dlgResult == DialogResult.OK)
                 {
                     //修改条件
                     Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(comboxCartype.SelectedValue.ToString());
                     //需要修改的内容
                     Action <PrintInfo> actions = p =>
                     {
                         p.Print_State = "暂停";
                     };
                     //执行更新
                     PrintInfoDAL.UpdatePrint(funs, actions);
                     PrintInfoDAL.InsertPrint(print);
                 }
                 else
                 {
                     print.Print_State = "暂停";
                     PrintInfoDAL.InsertPrint(print);
                 }
             }
             else
             {
                 PrintInfoDAL.InsertPrint(print);
             }
         }
         else
         {
             PrintInfoDAL.InsertPrint(print);
         }
         DataTable dt    = LinQBaseDao.Query("select PrintInfo_ID,PrintInfo_State from PrintInfo order by PrintInfo_ID desc ").Tables[0];
         string    id    = dt.Rows[0][0].ToString();
         string    state = dt.Rows[0][1].ToString();
         if (state == "启动")
         {
             CommonalityEntity.WriteLogData("新增", "新增并启动编号为:" + id + "打印设置", CommonalityEntity.USERNAME);
         }
         else
         {
             CommonalityEntity.WriteLogData("新增", "新增编号为:" + id + "打印设置", CommonalityEntity.USERNAME);
         }
     }
     catch
     {
         CommonalityEntity.WriteTextLog("PrintSetForm btnAdd_Click()");
     }
     finally
     {
         GetGriddataviewLoad("");
     }
 }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         //得到页面对应车辆类型的打印设置
         int carType_ID = int.Parse(comboxCartype.SelectedValue.ToString());
         //得到选择的打印内容
         string print_Content = "";
         if (chkStaff_Name.Checked)
         {
             print_Content += chkStaff_Name.Text.Trim() + ",";
         }
         if (chkCarNumber.Checked)
         {
             print_Content += chkCarNumber.Text.Trim() + ",";
         }
         if (chkCarType.Checked)
         {
             print_Content += chkCarType.Text.Trim() + ",";
         }
         if (chkList.CheckedItems.Count > 0)
         {
             foreach (var item in chkList.CheckedItems)
             {
                 print_Content += item + ",";
             }
         }
         if (chkPrint_State.Text.Trim() == "启动")
         {
             if (ChkPrintState())
             {
                 DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dlgResult == DialogResult.OK)
                 {
                     //修改条件
                     Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(comboxCartype.SelectedValue.ToString());
                     //需要修改的内容
                     Action <PrintInfo> actions = p =>
                     {
                         p.Print_State = "暂停";
                     };
                     //执行更新
                     PrintInfoDAL.UpdatePrint(funs, actions);
                 }
                 else
                 {
                     return;
                 }
             }
         }
         string id         = "";
         string strfront   = "";
         string strcontent = "";
         Expression <Func <PrintInfo, bool> > fun = p => p.Print_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString());
         Action <PrintInfo> action = print =>
         {
             strfront               = print.Print_Content + "," + print.Print_State + "," + print.Print_CarType_ID;
             print.Print_Content    = print_Content.Substring(0, print_Content.Length - 1);
             print.Print_State      = chkPrint_State.Text.Trim();
             print.Print_CarType_ID = carType_ID;
             print.Print_State      = chkPrint_State.Text.Trim();
             print.Print_Attention  = txtzhuyishixiang.Text.Trim();
             print.Print_Prompt     = txttisi.Text.Trim();
             strcontent             = print.Print_Content + "," + print.Print_State + "," + print.Print_CarType_ID;
             id = print.Print_ID.ToString();
         };
         PrintInfoDAL.UpdatePrint(fun, action);
         CommonalityEntity.WriteLogData("修改", "更新打印编号为:" + id + "的打印设置;修改前:" + strfront + ";修改后:" + strcontent, CommonalityEntity.USERNAME);
     }
     catch
     {
         CommonalityEntity.WriteTextLog("PrintSetForm btnUpdate_Click()");//记录异常日志
     }
     finally
     {
         GetGriddataviewLoad("");
         btnAdd.Enabled    = true;
         btnUpdate.Enabled = false;
     }
 }
Example #9
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            try
            {
                CheckProperties.ce.SapChengPinTable  = null;
                CheckProperties.ce.SapChengPinTable2 = null;
                CheckMethod.listMessage.Clear();
                CommonalityEntity.yxincheck = false;//是否系统自动进门授权
                SerialNumber = txtNumber.Text.Trim();
                if (string.IsNullOrEmpty(SerialNumber))
                {
                    MessageBox.Show(this, "小票号(IC卡)不能为空");
                    return;
                }
                string strsql = "";
                if (SerialNumber.Length >= 12)
                {
                    strsql = "select top 1 * from View_CarState where SmallTicket_Serialnumber= '" + SerialNumber + "' order by  SmallTicket_ID desc";
                }
                if (SerialNumber.Length == 9)
                {
                    strsql  = "select top 1 * from View_CarState where SmallTicket_ICCard_ID in( select ICCard_ID from ICCard where ICCard_Value ='" + SerialNumber + "') order by  SmallTicket_ID desc";
                    ICValue = SerialNumber;
                }
                if (string.IsNullOrEmpty(strsql))
                {
                    MessageBox.Show("小票号(IC卡)无效!");
                    return;
                }
                dtviewcarstate = LinQBaseDao.Query(strsql).Tables[0];
                if (dtviewcarstate.Rows.Count > 0)
                {
                    if (!ISfull())
                    {
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("小票号(IC卡)无效!");
                    return;
                }
                string Strategy_DriSName = "";//通行策略名称
                CommonalityEntity.IsUpdatedri = false;
                //查询车辆类型的通行策略
                DataTable DrivewayStrategy_IDDT = LinQBaseDao.Query("select DrivewayStrategy_ID,DrivewayStrategy_Sort ,DrivewayStrategy_Name,DrivewayStrategy_Driveway_ID from DrivewayStrategy where DrivewayStrategy_State='启动' and  DrivewayStrategy_Name in (select CarType_DriSName from CarType  where  CarType_Name='" + cmbCarType.Text + "') order by DrivewayStrategy_Sort ").Tables[0];

                if (DrivewayStrategy_IDDT.Rows.Count <= 0)
                {
                    MessageBox.Show("该车辆没有配通行策略!", "提示");
                    return;
                }
                Strategy_DriSName             = DrivewayStrategy_IDDT.Rows[0][2].ToString();
                CommonalityEntity.Driveway_ID = Convert.ToInt32(DrivewayStrategy_IDDT.Rows[0]["DrivewayStrategy_Driveway_ID"].ToString());
                DataTable dtption = LinQBaseDao.Query("select Driveway_Value,Position_ID,Position_Value,Position_State from View_DrivewayPosition where  Driveway_ID=" + CommonalityEntity.Driveway_ID).Tables[0];
                if (dtption.Rows.Count > 0)
                {
                    if (dtption.Rows[0]["Position_State"].ToString() != "启动")
                    {
                        MessageBox.Show(this, "通行门岗状态已暂停和注销!");
                        return;
                    }
                    CommonalityEntity.Driveway_Value = dtption.Rows[0]["Driveway_Value"].ToString();
                    CommonalityEntity.Position_ID    = Convert.ToInt32(dtption.Rows[0]["Position_ID"].ToString());
                    CommonalityEntity.Position_Value = dtption.Rows[0]["Position_Value"].ToString();
                }
                else
                {
                    MessageBox.Show(this, "门岗通道不存在,请检查!");
                    return;
                }

                string carname = dtviewcarstate.Rows[0]["CarInfo_Name"].ToString();
                CheckProperties.ce.CarInfo_ID     = Convert.ToInt32(dtviewcarstate.Rows[0]["CarInfo_ID"].ToString());
                CheckProperties.ce.ChengPinNumber = carname;
                CheckProperties.ce.carInfo_Name   = carname;

                if (ChkRepeat(carname))
                {
                    MessageBox.Show("不能重复登记该车辆!");
                    return;
                }

                string crSql = "select * from CarType where CarType_Name='" + cmbCarType.Text + "'";
                CheckProperties.ce.IsPhoto             = false;
                CheckProperties.ce.levelIsWaste        = false;
                CheckProperties.ce.isSort              = false;
                CheckProperties.ce.ISUpdateCredentials = false;
                CommonalityEntity.ISYX     = false;
                CheckProperties.ce.IsState = false;
                CarType cart = LinQBaseDao.GetItemsForListing <CarType>(crSql).FirstOrDefault();
                if (cart != null)
                {
                    CommonalityEntity.Car_Type_ID = cart.CarType_ID.ToString();
                    CheckProperties.ce.carType_ID = cart.CarType_ID;
                    CheckProperties.ce.CarTypeKey = cart.CarType_ID.ToString();
                    CommonalityEntity.CarType[cart.CarType_ID.ToString()] = cart.CarType_Name;
                    CheckProperties.ce.carType_Value = cart.CarType_Value;
                    CheckProperties.ce.CarType_Name  = cart.CarType_Name;
                }


                #region 执行登记管控

                //根据车辆类型,获取车辆类型的管控策略(登记管控)
                string sql = "";
                sql = "select * from  ManagementStrategy where ManagementStrategy_DriSName='" + Strategy_DriSName + "' and ManagementStrategy_Menu_ID=1  and ManagementStrategy_State='启动' and ManagementStrategy_Rule  in('ChkChengPin', 'ChkSapOflag','ISInCheckSapSave')  order by ManagementStrategy_No ";
                DataTable dtmstra = LinQBaseDao.Query(sql).Tables[0];

                if (dtmstra.Rows.Count > 0)
                {
                    CommonalityEntity.ISlogin = true;
                }
                else
                {
                    CommonalityEntity.ISlogin = false;
                }

                if (CommonalityEntity.ISlogin)
                {
                    sql = "select * from  ManagementStrategy where ManagementStrategy_DriSName='" + Strategy_DriSName + "' and ManagementStrategy_Menu_ID=1  and ManagementStrategy_State='启动' order by ManagementStrategy_No ";
                }
                else
                {
                    sql = "select * from  ManagementStrategy where ManagementStrategy_DriSName='" + Strategy_DriSName + "' and ManagementStrategy_Menu_ID=1  and ManagementStrategy_State='启动' and ManagementStrategy_Rule not in('ChkChengPin', 'ChkSapOflag','ISInCheckSapSave')  order by ManagementStrategy_No ";
                }
                try
                {
                    checkPr.ExecutionMethod(sql);//执行指定车辆类型的管控
                }
                catch { }


                #endregion

                //执行结果
                if (CheckMethod.listMessage.Count > 0)
                {
                    foreach (var item in CheckMethod.listMessage)
                    {
                        MessageBox.Show(item);
                        return;
                    }
                }

                string carId = "";
                Expression <Func <Car, bool> > carFn = n => n.Car_Name == CheckProperties.ce.carInfo_Name;
                Car car1 = CarDAL.Query(carFn).FirstOrDefault();
                if (car1 != null)
                {
                    carId = car1.Car_ID.ToString();
                }

                #region 车辆信息
                carInfo_ID = insertcar(carId);
                ErroSql.Add("delete carinfo where carinfo_id=" + carInfo_ID);
                #endregion

                #region 登记图片信息

                DataTable dt = LinQBaseDao.Query("select * from CarPic where CarPic_Type='车辆登记照片' and CarPic_CarInfo_ID=" + CheckProperties.ce.CarInfo_ID).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    string picSql = "Insert into CarPic(CarPic_CarInfo_ID,CarPic_State,CarPic_Add,CarPic_Type,CarPic_Time,CarPic_Match) values(" + carInfo_ID + ",'启动','" + dt.Rows[0]["CarPic_Add"].ToString() + "','车辆登记照片',getdate(),'匹配')";
                    picSql = picSql + " select @@identity";
                    string picid = LinQBaseDao.GetSingle(picSql).ToString();//得到当前的图片编号
                    ErroSql.Add("delete CarPic where CarPic_ID=" + picid);
                }
                #endregion

                #region 进出凭证信息
                SerialNumberNEW = CheckProperties.ce.serialNumber;
                CommonalityEntity.Serialnumber = SerialNumberNEW;
                SmallTicket stk = new SmallTicket();
                string      icid = "", count = "", hour = "";
                if (!string.IsNullOrEmpty(ICValue))
                {
                    dt = LinQBaseDao.Query("select * from ICCard where ICCard_Value='" + ICValue + "'").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        string ICCard_EffectiveType = dt.Rows[0]["ICCard_EffectiveType"].ToString();
                        string ICCard_count         = dt.Rows[0]["ICCard_count"].ToString();
                        string ICCard_HasCount      = dt.Rows[0]["ICCard_HasCount"].ToString();
                        string ICCard_State         = dt.Rows[0]["ICCard_State"].ToString();
                        icid = dt.Rows[0]["ICCard_ID"].ToString();
                        if (ICCard_EffectiveType == "次数")
                        {
                            int ct = Convert.ToInt32(ICCard_count);
                            int ht = Convert.ToInt32(ICCard_HasCount);
                            if (ct > ht)
                            {
                                count = (ct - ht).ToString();
                            }
                            else
                            {
                                count = "1";
                            }
                        }
                        if (ICCard_EffectiveType == "有效期")
                        {
                            DateTime ICCard_BeginTime = Convert.ToDateTime(dt.Rows[0]["ICCard_BeginTime"].ToString());
                            DateTime ICCard_EndTime   = Convert.ToDateTime(dt.Rows[0]["ICCard_EndTime"].ToString());
                            if (CommonalityEntity.GetServersTime() > ICCard_BeginTime && CommonalityEntity.GetServersTime() < ICCard_EndTime)
                            {
                                TimeSpan th = ICCard_EndTime - CommonalityEntity.GetServersTime();
                                int      s  = Convert.ToInt32(th.TotalHours);
                                if (s > 0)
                                {
                                    hour = s.ToString();
                                }
                                else
                                {
                                    hour = "1000";
                                }
                            }
                        }
                        if (ICCard_EffectiveType == "永久")
                        {
                            count = "1";
                        }
                    }
                }
                else
                {
                    hour  = CheckProperties.ce.serTime;
                    count = CheckProperties.ce.serCount;
                }

                if (string.IsNullOrEmpty(count))
                {
                    stk.SmallTicket_Allowcount = 1;
                }
                else
                {
                    stk.SmallTicket_Allowcount = int.Parse(count);
                }
                if (string.IsNullOrEmpty(hour))
                {
                    stk.SmallTicket_Allowhour = 0;
                }
                else
                {
                    stk.SmallTicket_Allowhour = int.Parse(hour);
                }

                if (CheckProperties.ce.isSort)
                {
                    //根据当前排队的序号,生成排队号
                    if (!CommonalityEntity.ISSecondXY)
                    {
                        DataTable dtm = LinQBaseDao.Query("select * from ManagementStrategy where ManagementStrategy_Rule='GetSortNumber' and ManagementStrategy_State='启动' and ManagementStrategy_Menu_ID=1 and ManagementStrategy_DriSName in (select CarType_DriSName from CarType where CarType_ID=" + cmbCarType.SelectedValue + ")").Tables[0];

                        if (dtm.Rows.Count > 0)
                        {
                            CheckMethod.GetSortNumber();
                        }
                        string number = CommonalityEntity.SortNumber(CheckProperties.ce.sort_Value);
                        stk.SmallTicket_SortNumber = CommonalityEntity.Position_Value + CheckProperties.ce.carType_Value + number;
                    }
                    else
                    {
                        stk.SmallTicket_SortNumber = "";
                    }
                }
                else
                {
                    stk.SmallTicket_SortNumber = "";
                }
                stk.SmallTicket_CarInfo_ID = carInfo_ID;
                if (!string.IsNullOrEmpty(icid))
                {
                    stk.SmallTicket_Type      = "IC卡";
                    stk.SmallTicket_ICCard_ID = Convert.ToInt32(icid);
                }
                stk.SmallTicket_Position_ID = SystemClass.PositionID;
                stk.SmallTicket_PrintNumber = "";
                stk.SmallTicket_Remark      = "";
                stk.SmallTicket_State       = "有效";
                stk.SmallTicket_Time        = CommonalityEntity.GetServersTime();
                if (SerialNumber.Trim() != "")
                {
                    DataTable dtm = LinQBaseDao.Query("select * from ManagementStrategy where ManagementStrategy_Rule='ChkSerialNumber' and ManagementStrategy_State='启动' and ManagementStrategy_Menu_ID=1 and ManagementStrategy_DriSName in (select CarType_DriSName from CarType where CarType_ID=" + cmbCarType.SelectedValue + ")").Tables[0];

                    if (dtm.Rows.Count > 0)
                    {
                        CheckMethod.ChkSerialNumber();
                        SerialNumberNEW = CheckProperties.ce.serialNumber;
                    }
                    stk.SmallTicket_Type        += "小票";
                    stk.SmallTicket_Serialnumber = SerialNumberNEW.Trim();
                }
                string SmalltSql = "";
                if (stk.SmallTicket_ICCard_ID.ToString() != "")//判断IC卡是否输入
                {
                    SmalltSql = "insert into SmallTicket values(" + stk.SmallTicket_ICCard_ID + ",'" + stk.SmallTicket_Serialnumber + "'," + stk.SmallTicket_Position_ID + "," + stk.SmallTicket_CarInfo_ID + ",'" + stk.SmallTicket_Time + "','" + stk.SmallTicket_SortNumber + "','" + stk.SmallTicket_PrintNumber + "','" + stk.SmallTicket_State + "','" + stk.SmallTicket_Type + "','" + stk.SmallTicket_Allowcounted + "','" + stk.SmallTicket_Allowcount + "','" + stk.SmallTicket_Allowhour + "','" + stk.SmallTicket_Remark + "')";
                }
                else
                {
                    SmalltSql = "insert into SmallTicket values(null,'" + stk.SmallTicket_Serialnumber + "'," + stk.SmallTicket_Position_ID + "," + stk.SmallTicket_CarInfo_ID + ",'" + stk.SmallTicket_Time + "','" + stk.SmallTicket_SortNumber + "','" + stk.SmallTicket_PrintNumber + "','" + stk.SmallTicket_State + "','" + stk.SmallTicket_Type + "','" + stk.SmallTicket_Allowcounted + "','" + stk.SmallTicket_Allowcount + "','" + stk.SmallTicket_Allowhour + "','" + stk.SmallTicket_Remark + "')";
                }
                SmalltSql      = SmalltSql + " select @@identity";
                smallTicket_ID = int.Parse(LinQBaseDao.GetSingle(SmalltSql).ToString());//得到当前的车辆编号
                ErroSql.Add("delete SmallTicket where SmallTicket_id=" + smallTicket_ID);
                #endregion

                #region 排队信息
                SortNumberInfo sort = new SortNumberInfo();
                //根据车辆类型  得到该车辆类型的信息
                sort.SortNumberInfo_DrivewayValue = CommonalityEntity.Driveway_Value;
                //门岗值
                sort.SortNumberInfo_PositionValue = CommonalityEntity.Position_Value;

                //车辆类型值
                sort.SortNumberInfo_CarTypeValue = CheckProperties.ce.carType_Value;
                //呼叫次数
                sort.SortNumberInfo_CallCount = 0;

                sort.SortNumberInfo_LEDCount = 0;
                sort.SortNumberInfo_Operate  = CommonalityEntity.USERNAME;

                //生成原因
                sort.SortNumberInfo_Reasons = "登记生成";
                sort.SortNumberInfo_Remark  = "";
                //凭证编号
                sort.SortNumberInfo_SmallTicket_ID = smallTicket_ID;
                sort.SortNumberInfo_SMSCount       = 0;

                if (CheckProperties.ce.isSort)
                {
                    if (!CommonalityEntity.ISSecondXY)
                    {
                        sort.SortNumberInfo_SortValue = CheckProperties.ce.sort_Value + 1;
                        sort.SortNumberInfo_TongXing  = "排队中";
                    }
                    else
                    {
                        CommonalityEntity.ISSecondXY  = false;
                        sort.SortNumberInfo_SortValue = null;
                        sort.SortNumberInfo_TongXing  = "待通行";
                    }
                }
                else
                {
                    sort.SortNumberInfo_SortValue = null;
                    sort.SortNumberInfo_TongXing  = "待通行";
                }
                sort.SortNumberInfo_State = "启动";
                sort.SortNumberInfo_Type  = "系统生成";
                sort.SortNumberInfo_Time  = CommonalityEntity.GetServersTime();

                //添加排队信息
                string sort_Sql = "insert into SortNumberInfo values('" + sort.SortNumberInfo_SmallTicket_ID + "','" + sort.SortNumberInfo_Time + "','" + sort.SortNumberInfo_Reasons + "','" + sort.SortNumberInfo_Operate + "','" + sort.SortNumberInfo_Type + "','" + sort.SortNumberInfo_SortValue + "','" + sort.SortNumberInfo_PositionValue + "','" + sort.SortNumberInfo_CarTypeValue + "','" + sort.SortNumberInfo_CallCount + "','" + sort.SortNumberInfo_SMSCount + "','" + sort.SortNumberInfo_LEDCount + "','" + sort.SortNumberInfo_Remark + "','" + sort.SortNumberInfo_TongXing + "','" + sort.SortNumberInfo_DrivewayValue + "','" + sort.SortNumberInfo_State + "','" + sort.SortNumberInfo_CallTime + "','" + sort.SortNumberInfo_Number + "', 1 ,0)";
                sort_Sql          = sort_Sql + " select @@identity";
                sortNumberInfo_ID = int.Parse(LinQBaseDao.GetSingle(sort_Sql).ToString());
                ErroSql.Add("delete SortNumberInfo where SortNumberInfo_ID=" + sortNumberInfo_ID);//增删改出错后需要执行的SQL
                #endregion

                #region 添加通行总记录
                CarInOutRecord cir         = new CarInOutRecord();
                string         strstrategy = "";
                bool           issort      = false;
                cir.CarInOutRecord_DrivewayStrategy_ID = Convert.ToInt32(DrivewayStrategy_IDDT.Rows[0]["DrivewayStrategy_ID"].ToString());

                for (int i = 0; i < DrivewayStrategy_IDDT.Rows.Count; i++)
                {
                    if (Convert.ToInt32(DrivewayStrategy_IDDT.Rows[i]["DrivewayStrategy_Sort"].ToString()) == 1)
                    {
                        issort       = false;
                        strstrategy += DrivewayStrategy_IDDT.Rows[i]["DrivewayStrategy_ID"].ToString() + ",";
                    }
                    else
                    {
                        issort       = true;
                        strstrategy += DrivewayStrategy_IDDT.Rows[i]["DrivewayStrategy_ID"].ToString() + ",";
                    }
                }
                cir.CarInOutRecord_ISFulfill         = false;
                cir.CarInOutRecord_Abnormal          = "正常";
                cir.CarInOutRecord_State             = "启动";
                cir.CarInOutRecord_DrivewayStrategyS = strstrategy.TrimEnd(',');
                cir.CarInOutRecord_CarInfo_ID        = carInfo_ID;
                cir.CarInOutRecord_Update            = false;
                cir.CarInOutRecord_Driveway_ID       = CommonalityEntity.Driveway_ID;
                if (issort)
                {
                    cir.CarInOutRecord_Sort = "有序";
                }
                else
                {
                    cir.CarInOutRecord_Sort = "无序";
                }

                string CarInOutRecordSql = "Insert into CarInOutRecord(CarInOutRecord_CarInfo_ID,CarInOutRecord_DrivewayStrategy_ID,CarInOutRecord_ISFulfill,CarInOutRecord_Time,CarInOutRecord_Abnormal,CarInOutRecord_State,CarInOutRecord_DrivewayStrategyS,CarInOutRecord_Sort,CarInOutRecord_Update,CarInOutRecord_Driveway_ID,CarInOutRecord_InCheck,CarInOutRecord_Remark) values(" + cir.CarInOutRecord_CarInfo_ID + "," + cir.CarInOutRecord_DrivewayStrategy_ID + ",'" + cir.CarInOutRecord_ISFulfill + "',getdate(),'正常','启动','" + cir.CarInOutRecord_DrivewayStrategyS + "','" + cir.CarInOutRecord_Sort + "','" + cir.CarInOutRecord_Update + "'," + cir.CarInOutRecord_Driveway_ID + ",'否','" + Strategy_DriSName + "')";
                CarInOutRecordSql = CarInOutRecordSql + " select @@identity";
                CarInOutRecord_ID = int.Parse(LinQBaseDao.GetSingle(CarInOutRecordSql).ToString());
                ErroSql.Add("delete CarInOutRecord where CarInOutRecord_ID=" + CarInOutRecord_ID);
                #endregion

                #region 添加关联表信息
                string staid   = dtviewcarstate.Rows[0]["StaffInfo_ID"].ToString();
                string sfCrSql = "Insert into StaffInfo_CarInfo values(" + staid + "," + smallTicket_ID + ")";
                sfCrSql = sfCrSql + " select @@identity";
                int sfCrID = int.Parse(LinQBaseDao.GetSingle(sfCrSql).ToString());
                ErroSql.Add("delete StaffInfo_CarInfo where StaffInfo_CarInfo_ID=" + sfCrID);
                #endregion

                if (CommonalityEntity.yxincheck)
                {
                    LinQBaseDao.Query("update CarInOutRecord set CarInOutRecord_InCheck='是',CarInOutRecord_InCheckTime=GETDATE(),CarInOutRecord_InCheckUser='******' where CarInOutRecord_ID=" + CarInOutRecord_ID);
                }

                #region 判断是否添加成功
                if (sortNumberInfo_ID > 0 && smallTicket_ID > 0 && carInfo_ID > 0 && CarInOutRecord_ID != -1)
                {
                    if (CommonalityEntity.SAP_ID != "" && SerialNumberNEW != "")
                    {
                        LinQBaseDao.Query("update eh_SAPRecord set Sap_Serialnumber=" + SerialNumberNEW + " where Sap_ID=" + CommonalityEntity.SAP_ID);
                        CommonalityEntity.SAP_ID = "";
                        if (!CommonalityEntity.GetSAP(PNO, "A", carname, SerialNumberNEW, "1"))
                        {
                            MessageBox.Show("成品纸车辆SAP验证未通过!");
                            return;
                        }
                    }
                    if (CommonalityEntity.SAP_ID != "" && SerialNumberNEW == "" && ICValue != "")
                    {
                        LinQBaseDao.Query("update eh_SAPRecord set Sap_Serialnumber=" + ICValue + " where Sap_ID=" + CommonalityEntity.SAP_ID);
                        CommonalityEntity.SAP_ID = "";
                        if (!CommonalityEntity.GetSAP(PNO, "A", carname, ICValue, "1"))
                        {
                            MessageBox.Show("成品纸车辆SAP验证未通过!");
                            return;
                        }
                    }

                    CommonalityEntity.CarInfo_ID = carInfo_ID.ToString();

                    MessageBox.Show(this, "成品二次排队成功");
                    CommonalityEntity.WriteLogData("新增", "新增:" + carname + "车辆二次排队", CommonalityEntity.USERNAME);//添加操作日志

                    if (!string.IsNullOrEmpty(CommonalityEntity.SAP_ID))
                    {
                        DataTable dtsap = LinQBaseDao.Query("select  Sap_InNO,Sap_OutHG,Sap_OutXZ  from eh_SAPRecord where Sap_ID=" + CommonalityEntity.SAP_ID).Tables[0];
                        if (dtsap.Rows.Count > 0)
                        {
                            if (CommonalityEntity.SAP_ID != "" && SerialNumber != "")
                            {
                                LinQBaseDao.Query("update eh_SAPRecord set Sap_Serialnumber=" + SerialNumberNEW + " where Sap_ID=" + CommonalityEntity.SAP_ID);
                                CommonalityEntity.SAP_ID = "";
                                if (!CommonalityEntity.GetSAP(dtsap.Rows[0]["Sap_InNO"].ToString(), "A", carname, SerialNumberNEW, "1"))
                                {
                                    MessageBox.Show("成品车辆SAP验证未通过!");
                                    return;
                                }
                            }
                        }
                    }

                    //获取打印设置
                    string prtSql = "select top 1 * from PrintInfo where Print_State='启动' and Print_CarType_ID=" + CheckProperties.ce.carType_ID + "";
                    if (CheckProperties.ce.isSerialNumber)
                    {
                        CheckProperties.ce.isSerialNumber = false;
                        PrintInfo pinfo = PrintInfoDAL.GetPrint(prtSql);

                        if (pinfo.Print_ID > 0)
                        {
                            if (SerialNumberNEW != "")
                            {
                                string   prSql = "Select top 1  ";
                                string[] str   = pinfo.Print_Content.Split(',');
                                foreach (var item in str)
                                {
                                    prSql += item + ",";
                                }
                                prSql  = prSql.Substring(0, prSql.Length - 1);
                                prSql += " from View_LEDShow_zj where 小票号='" + SerialNumberNEW + "' and smallTicket_State='有效'";
                                DataSet ds = LinQBaseDao.Query(prSql);
                                CommonalityEntity.Serialnumber = SerialNumberNEW;
                                PrintInfoForm pi = new PrintInfoForm(ds);
                                pi.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("没有进行打印设置,请设置打印后,重新打印");
                            return;
                        }
                    }
                }
                #endregion
            }
            catch
            {
                MessageBox.Show("成品二次排队失败!");
                CommonalityEntity.WriteTextLog("ProductForm btnCheck_Click()");
                try
                {
                    string sqlstr = "";
                    for (int i = 0; i < ErroSql.Count; i++)
                    {
                        sqlstr += ErroSql[i] + "     ";
                    }
                    LinQBaseDao.Query(sqlstr);
                }
                catch
                {
                    CommonalityEntity.WriteTextLog("ProductForm btnCheck_Click()");
                }
            }
        }