Ejemplo n.º 1
0
        /// <summary>
        /// 新增一条记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneQCRecord(DrivewayStrategyRecord qcRecord)
        {
            bool rbool = true;

            using (DCCarManagementDataContext db = new DCCarManagementDataContext())
            {
                try
                {
                    rbool = LinQBaseDao.InsertOne(db, qcRecord);
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存,如果有同样车牌号的通行策略则把之前的状态注销
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            IList <DrivewayStrategyRecord> iedsr = null;

            try
            {
                if (string.IsNullOrEmpty(txt_carState.Text))
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "请选择状态!", txt_carState, this);
                    return;
                }
                string strsort = "";
                if (SortYesOrNo)
                {
                    strsort = "有序";
                }
                else
                {
                    strsort = "无序";
                }
                if (SetSortList.Count != Driveway_IDList.Count)
                {
                    SortYesOrNo = false;
                }
                else
                {
                    SortYesOrNo = true;
                }
                //得到车辆对象
                Expression <Func <CarInfo, bool> > fn = n => n.CarInfo_ID == Convert.ToInt32(CommonalityEntity.CarInfo_ID);
                CarInfo car = CarInfoDAL.Single(fn);


                LinQBaseDao.Query("delete ManagementStrategyRecord where ManagementStrategyRecord_CarInfo_ID=" + car.CarInfo_ID);
                LinQBaseDao.Query("delete DrivewayStrategyRecord where DrivewayStrategyRecord_CarInfo_ID=" + car.CarInfo_ID);

                //循环选择的通道
                iedsr = new List <DrivewayStrategyRecord>();

                if (SetSortList.Count == Driveway_IDList.Count)
                {
                    for (int i = 0; i < SetSortList.Count; i++)
                    {
                        DataTable tablesDrisn = LinQBaseDao.Query("select Position_Name,Driveway_Name,Driveway_type from View_DrivewayPosition where driveway_warrantystate='正常' and driveway_state='启动' and Driveway_ID=" + SetSortList[i].id + "  order by Position_Name asc, Driveway_Name asc").Tables[0];

                        DrivewayStrategyRecord Newdsr = new DrivewayStrategyRecord();
                        Newdsr.DrivewayStrategyRecord_Name        = txtDrivewayStrategy.Text.Trim();
                        Newdsr.DrivewayStrategyRecord_Driveway_ID = SetSortList[i].id;//通道编号
                        Newdsr.DrivewayStrategyRecord_State       = txt_carState.Text;
                        Newdsr.DrivewayStrategyRecord_Remark      = txt_DrivewayStrategyRecord_Remark.Text.Trim();
                        Newdsr.DrivewayStrategyRecord_OffReason   = txt_DrivewayStrategyRecord_OffReason.Text.Trim();
                        Newdsr.DrivewayStrategyRecord_OffTime     = CommonalityEntity.GetServersTime();
                        Newdsr.DrivewayStrategyRecord_OffName     = HelpClass.common.USERNAME;
                        Newdsr.DrivewayStrategyRecord_CarInfo_ID  = car.CarInfo_ID;
                        Newdsr.DrivewayStrategyRecord_Sort        = SortYesOrNo == true ? SetSortList[i].sort : 1;
                        Newdsr.DrivewayStrategyRecord_Record      = "【" + txt_carInfo_Name.Text.ToString().Trim() + "】 " + tablesDrisn.Rows[0]["Position_Name"] + tablesDrisn.Rows[0]["Driveway_Name"];
                        iedsr.Add(Newdsr);
                    }

                    try
                    {
                        dc.DrivewayStrategyRecord.InsertAllOnSubmit(iedsr);
                        dc.SubmitChanges();



                        DialogResult dr = MessageBox.Show("操作已完成!请继续修改相应的管控策略否则修改无效", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                        if (dr == DialogResult.Yes)
                        {
                            string sids = "";

                            DataTable dt = LinQBaseDao.Query("select DrivewayStrategyRecord_ID, DrivewayStrategyRecord_Driveway_ID from DrivewayStrategyRecord where DrivewayStrategyRecord_CarInfo_ID=" + car.CarInfo_ID + " and DrivewayStrategyRecord_State='启动' order by DrivewayStrategyRecord_Sort ").Tables[0];
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                sids += dt.Rows[i][0].ToString() + ",";
                            }
                            int driid = Convert.ToInt32(dt.Rows[0][1].ToString());
                            sids = sids.TrimEnd(',');
                            string SmallID = LinQBaseDao.GetSingle("select SmallTicket_ID from SmallTicket where SmallTicket_CarInfo_ID=" + car.CarInfo_ID).ToString();

                            DataTable dtpd = LinQBaseDao.Query("select Position_ID, Position_Value,Driveway_Value from View_FVN_Driveway_Position where Driveway_ID=" + driid).Tables[0];
                            if (dtpd.Rows.Count > 0)
                            {
                                string str = "update CarInOutRecord set CarInOutRecord_DrivewayStrategyS='" + sids + "',CarInOutRecord_Update=1,CarInOutRecord_Driveway_ID=" + driid + ",CarInOutRecord_Remark='" + txtDrivewayStrategy.Text.Trim() + "',CarInOutRecord_Sort='" + strsort + "' where CarInOutRecord_CarInfo_ID=" + car.CarInfo_ID;
                                str += " update SortNumberInfo set  SortNumberInfo_PositionValue='" + dtpd.Rows[0][1].ToString() + "',SortNumberInfo_DrivewayValue='" + dtpd.Rows[0][2].ToString() + "' where  SortNumberInfo_SmallTicket_ID in (select SmallTicket_ID from SmallTicket where SmallTicket_CarInfo_ID=" + car.CarInfo_ID + ")";
                                LinQBaseDao.Query(str);

                                sids = "";
                                CommonalityEntity.boolCepyManagementStrategy = false;
                                UpdateManagementStrategyForm up = new UpdateManagementStrategyForm(carname);
                                up.Show();
                            }
                        }
                        BingMethod();
                    }
                    catch
                    {
                        MessageBox.Show("操作失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("DrivewayStrategyRecordForm.btnUpdate_Click()" + "".ToString());
            }
            finally
            {
                SetSortList.Clear();
                Driveway_IDList.Clear();
            }
        }