Exemplo n.º 1
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>
 /// 保存设置
 /// </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("");
     }
 }