예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hotel_app.Model.Q_sfz_save model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Q_sfz_save set ");
            strSql.Append("zjhm=@zjhm,");
            strSql.Append("krxm=@krxm,");
            strSql.Append("krmz=@krmz,");
            strSql.Append("krxb=@krxb,");
            strSql.Append("krsr=@krsr,");
            strSql.Append("krdz=@krdz,");
            strSql.Append("department=@department,");
            strSql.Append("startdate=@startdate,");
            strSql.Append("enddate=@enddate,");
            strSql.Append("krxp=@krxp,");
            strSql.Append("shsc=@shsc");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@zjhm",       SqlDbType.VarChar,    50),
                new SqlParameter("@krxm",       SqlDbType.VarChar,    50),
                new SqlParameter("@krmz",       SqlDbType.VarChar,    50),
                new SqlParameter("@krxb",       SqlDbType.VarChar,    50),
                new SqlParameter("@krsr",       SqlDbType.DateTime),
                new SqlParameter("@krdz",       SqlDbType.VarChar,   200),
                new SqlParameter("@department", SqlDbType.VarChar,    50),
                new SqlParameter("@startdate",  SqlDbType.DateTime),
                new SqlParameter("@enddate",    SqlDbType.DateTime),
                new SqlParameter("@krxp",       SqlDbType.Image),
                new SqlParameter("@shsc",       SqlDbType.Bit,         1),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.zjhm;
            parameters[1].Value  = model.krxm;
            parameters[2].Value  = model.krmz;
            parameters[3].Value  = model.krxb;
            parameters[4].Value  = model.krsr;
            parameters[5].Value  = model.krdz;
            parameters[6].Value  = model.department;
            parameters[7].Value  = model.startdate;
            parameters[8].Value  = model.enddate;
            parameters[9].Value  = model.krxp;
            parameters[10].Value = model.shsc;
            parameters[11].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hotel_app.Model.Q_sfz_save model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Q_sfz_save(");
            strSql.Append("zjhm,krxm,krmz,krxb,krsr,krdz,department,startdate,enddate,krxp,shsc)");
            strSql.Append(" values (");
            strSql.Append("@zjhm,@krxm,@krmz,@krxb,@krsr,@krdz,@department,@startdate,@enddate,@krxp,@shsc)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@zjhm",       SqlDbType.VarChar,    50),
                new SqlParameter("@krxm",       SqlDbType.VarChar,    50),
                new SqlParameter("@krmz",       SqlDbType.VarChar,    50),
                new SqlParameter("@krxb",       SqlDbType.VarChar,    50),
                new SqlParameter("@krsr",       SqlDbType.DateTime),
                new SqlParameter("@krdz",       SqlDbType.VarChar,   200),
                new SqlParameter("@department", SqlDbType.VarChar,    50),
                new SqlParameter("@startdate",  SqlDbType.DateTime),
                new SqlParameter("@enddate",    SqlDbType.DateTime),
                new SqlParameter("@krxp",       SqlDbType.Image),
                new SqlParameter("@shsc",       SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.zjhm;
            parameters[1].Value  = model.krxm;
            parameters[2].Value  = model.krmz;
            parameters[3].Value  = model.krxb;
            parameters[4].Value  = model.krsr;
            parameters[5].Value  = model.krdz;
            parameters[6].Value  = model.department;
            parameters[7].Value  = model.startdate;
            parameters[8].Value  = model.enddate;
            parameters[9].Value  = model.krxp;
            parameters[10].Value = model.shsc;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 private void button10_Click(object sender, EventArgs e)
 {
     Model.Q_sfz_save M_Q_sfz_save = new Hotel_app.Model.Q_sfz_save();
     BLL.Q_sfz_save   B_Q_sfz_save = new Hotel_app.BLL.Q_sfz_save();
     M_Q_sfz_save = B_Q_sfz_save.GetModel(1);
     if (M_Q_sfz_save != null)
     {
         byte[] b = (byte[])M_Q_sfz_save.krxp;
         if (b.Length > 0)
         {
             MemoryStream stream = new MemoryStream(b, true);
             stream.Write(b, 0, b.Length);
             pictureBox1.Image = new Bitmap(stream);
             stream.Close();
         }
     }
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hotel_app.Model.Q_sfz_save GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,zjhm,krxm,krmz,krxb,krsr,krdz,department,startdate,enddate,krxp,shsc from Q_sfz_save ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Hotel_app.Model.Q_sfz_save model = new Hotel_app.Model.Q_sfz_save();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["zjhm"] != null && ds.Tables[0].Rows[0]["zjhm"].ToString() != "")
                {
                    model.zjhm = ds.Tables[0].Rows[0]["zjhm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krxm"] != null && ds.Tables[0].Rows[0]["krxm"].ToString() != "")
                {
                    model.krxm = ds.Tables[0].Rows[0]["krxm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krmz"] != null && ds.Tables[0].Rows[0]["krmz"].ToString() != "")
                {
                    model.krmz = ds.Tables[0].Rows[0]["krmz"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krxb"] != null && ds.Tables[0].Rows[0]["krxb"].ToString() != "")
                {
                    model.krxb = ds.Tables[0].Rows[0]["krxb"].ToString();
                }
                if (ds.Tables[0].Rows[0]["krsr"] != null && ds.Tables[0].Rows[0]["krsr"].ToString() != "")
                {
                    model.krsr = DateTime.Parse(ds.Tables[0].Rows[0]["krsr"].ToString());
                }
                if (ds.Tables[0].Rows[0]["krdz"] != null && ds.Tables[0].Rows[0]["krdz"].ToString() != "")
                {
                    model.krdz = ds.Tables[0].Rows[0]["krdz"].ToString();
                }
                if (ds.Tables[0].Rows[0]["department"] != null && ds.Tables[0].Rows[0]["department"].ToString() != "")
                {
                    model.department = ds.Tables[0].Rows[0]["department"].ToString();
                }
                if (ds.Tables[0].Rows[0]["startdate"] != null && ds.Tables[0].Rows[0]["startdate"].ToString() != "")
                {
                    model.startdate = DateTime.Parse(ds.Tables[0].Rows[0]["startdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["enddate"] != null && ds.Tables[0].Rows[0]["enddate"].ToString() != "")
                {
                    model.enddate = DateTime.Parse(ds.Tables[0].Rows[0]["enddate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["krxp"] != null && ds.Tables[0].Rows[0]["krxp"].ToString() != "")
                {
                    model.krxp = (byte[])ds.Tables[0].Rows[0]["krxp"];
                }
                if (ds.Tables[0].Rows[0]["shsc"] != null && ds.Tables[0].Rows[0]["shsc"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["shsc"].ToString() == "1") || (ds.Tables[0].Rows[0]["shsc"].ToString().ToLower() == "true"))
                    {
                        model.shsc = true;
                    }
                    else
                    {
                        model.shsc = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
            /// <summary>
            /// 读取身份证信息
            /// </summary>
            /// <param name="tBkrxm"></param>
            /// <param name="tBkrxb"></param>
            /// <param name="tBnation"></param>
            /// <param name="tBadd"></param>
            /// <param name="tBid"></param>
            /// <param name="tBkrsr"></param>
            /// <param name="tBdepart"></param>
            /// <param name="tBstart"></param>
            /// <param name="tBend"></param>
            /// <param name="imakrxp"></param>
            /// <param name="sh_massage"></param>
            /// <param name="massage_nr"></param>
            /// <returns></returns>
            public string get_sfz_info(ref string tBkrxm, ref string tBkrxb, ref string tBnation, ref string tBadd, ref string tBid, ref string tBkrsr, ref string tBdepart, ref string tBstart, ref string tBend, ref byte[] imakrxp, bool sh_massage, ref string massage_nr)
            {
                string s_0        = "";
                int    tempReturn = 0;
                bool   usbPort    = false;

                try
                {
                    for (int port = 1001; port <= 1006; port++)
                    {
                        tempReturn = InitComm(port);
                        if (tempReturn == 1)
                        {
                            usbPort = true;
                            UsePort = port;
                            break;
                        }
                    }
                    //检测串口的机具连接
                    if (!usbPort)
                    {
                        for (int port = 1; port <= 6; port++)
                        {
                            tempReturn = InitComm(port);
                            if (tempReturn == 1)
                            {
                                usbPort = false;
                                UsePort = port;
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
                finally
                {
                }


                if (tempReturn != 1)
                {
                    if (sh_massage == true)
                    {
                        common_file.common_app.Message_box_show(common_file.common_app.message_title, "端口打开失败,请检测相应的端口或者重新连接读卡器!");
                    }
                    else
                    {
                        massage_nr = "端口打开失败,请检测相应的端口或者重新连接读卡器!";
                    }
                    try
                    {
                        CloseComm();
                    }
                    catch
                    {
                    }
                }
                else
                {
                    try
                    {
                        CloseComm();
                        InitComm(UsePort);
                        Authenticate();
                        if (Read_Content(1) != 1)
                        {
                            if (sh_massage == true)
                            {
                                common_file.common_app.Message_box_show(common_file.common_app.message_title, "读卡失败,请确认是否把有效的二代身份证放在读卡器上!");
                            }
                            else
                            {
                                massage_nr = "读卡失败,请确认是否把有效的二代身份证放在读卡器上!";
                            }
                            CloseComm();
                        }
                        else
                        {
                            string cznr = "";
                            string czzy = "";
                            string czbz = "";
                            try
                            {
                                int           i      = 0;
                                StringBuilder szName = new StringBuilder(NameLen);
                                add_info(ref szName, NameLen);
                                czzy   = "1" + szName.ToString();
                                i      = GetPeopleName(szName, NameLen);
                                czzy   = "1" + szName.ToString();
                                tBkrxm = szName.ToString().Trim().Replace(bs, "");

                                cznr = "客人姓名";

                                StringBuilder szSex = new StringBuilder(SexLen);
                                add_info(ref szSex, SexLen);
                                czzy   = "2" + szSex.ToString();
                                i      = GetPeopleSex(szSex, SexLen);
                                czzy   = "2" + szSex.ToString();
                                tBkrxb = szSex.ToString().Trim().Replace(bs, "");

                                cznr = "性别";

                                StringBuilder szNation = new StringBuilder(NationLen);
                                add_info(ref szNation, NationLen);
                                czzy     = "3" + szNation.ToString();
                                i        = GetPeopleNation(szNation, NationLen);
                                czzy     = "3" + szNation.ToString();
                                tBnation = szNation.ToString().Trim().Replace(bs, "");

                                cznr = "民族";

                                StringBuilder szBirthday = new StringBuilder(DateLen);
                                add_info(ref szBirthday, DateLen);
                                czzy   = "4" + szBirthday.ToString();
                                i      = GetPeopleBirthday(szBirthday, DateLen);
                                czzy   = "4" + szBirthday.ToString();
                                tBkrsr = szBirthday.ToString().Trim().Replace(bs, "");

                                cznr = "生日";


                                StringBuilder szID = new StringBuilder(IdLen);
                                add_info(ref szID, IdLen);
                                czzy = "5" + szID.ToString();
                                i    = GetPeopleIDCode(szID, IdLen);
                                czzy = "5" + szID.ToString();
                                tBid = szID.ToString().Trim().Replace(bs, "");


                                cznr = "号码";


                                StringBuilder szStartDate = new StringBuilder(StartdateLen);
                                add_info(ref szStartDate, StartdateLen);
                                czzy    = "6" + szStartDate.ToString();
                                i       = GetStartDate(szStartDate, StartdateLen);
                                czzy    = "6" + szStartDate.ToString();
                                tBstart = szStartDate.ToString().Trim().Replace(bs, "");


                                cznr = "开始";

                                StringBuilder szEndDate = new StringBuilder(EnddateLen);
                                add_info(ref szEndDate, EnddateLen);
                                czzy  = "7" + szEndDate.ToString();
                                i     = GetEndDate(szEndDate, EnddateLen);
                                czzy  = "7" + szEndDate.ToString();
                                tBend = szEndDate.ToString().Trim().Replace(bs, "");

                                cznr = "结束";

                                StringBuilder szDepartment = new StringBuilder(DepartmentLen);
                                add_info(ref szDepartment, DepartmentLen);
                                czzy     = "8" + szDepartment.ToString();
                                i        = GetDepartment(szDepartment, DepartmentLen);
                                czzy     = "8" + szDepartment.ToString();
                                tBdepart = szDepartment.ToString().Trim().Replace(bs, "");


                                cznr = "部门";


                                StringBuilder szAddress = new StringBuilder(AddrLen);
                                add_info(ref szAddress, AddrLen);
                                czzy  = "9" + szAddress.ToString();
                                i     = GetPeopleAddress(szAddress, AddrLen);
                                czzy  = "9" + szAddress.ToString();
                                tBadd = szAddress.ToString().Trim().Replace(bs, "");

                                cznr = "地址";


                                Beep(2047, 300);
                                CloseComm();



                                if (tBid != "")
                                {
                                    BLL.Q_sfz_save B_Q_sfz_save = new Hotel_app.BLL.Q_sfz_save();
                                    DataSet        ds_temp      = B_Q_sfz_save.GetList("zjhm='" + tBid + "'");
                                    if (ds_temp != null && ds_temp.Tables[0].Rows.Count > 0)
                                    {
                                    }
                                    else
                                    {
                                        cznr = "输入数据"; czzy = cznr;
                                        byte[]     imageb   = new byte[0];
                                        string     savePath = Application.StartupPath + @"\ZP.bmp";
                                        FileStream fs       = System.IO.File.OpenRead(savePath);

                                        imageb = new byte[fs.Length];
                                        cznr   = "读图前"; czzy = cznr;
                                        fs.Read(imageb, 0, imageb.Length);
                                        cznr = "读图后"; czzy = cznr;
                                        Model.Q_sfz_save M_Q_sfz_save = new Hotel_app.Model.Q_sfz_save();
                                        cznr = "生成模前"; czzy = cznr;
                                        M_Q_sfz_save.zjhm = tBid;
                                        cznr = "生成模" + tBid; czzy = cznr;
                                        M_Q_sfz_save.krdz = tBadd;
                                        cznr = "生成模" + tBadd; czzy = cznr;
                                        M_Q_sfz_save.krmz = tBnation;
                                        cznr = "生成模" + tBnation; czzy = cznr;
                                        M_Q_sfz_save.krsr = DateTime.Parse(tBkrsr.Substring(0, 4) + "-" + tBkrsr.Substring(4, 2) + "-" + tBkrsr.Substring(6, 2));
                                        cznr = "生成模" + M_Q_sfz_save.krsr; czzy = cznr;
                                        M_Q_sfz_save.krxb = tBkrxb;
                                        cznr = "生成模" + tBkrxb; czzy = cznr;
                                        M_Q_sfz_save.krxm = tBkrxm;
                                        cznr = "生成模" + tBkrxm; czzy = cznr;

                                        fs.Flush();
                                        fs.Close();

                                        if (tBstart.Length > 9)
                                        {
                                            M_Q_sfz_save.startdate = DateTime.Parse(tBstart.Substring(0, 4) + "-" + tBstart.Substring(4, 2) + "-" + tBstart.Substring(6, 2));
                                            cznr = "生成模始" + tBstart.Substring(0, 4) + "-" + tBstart.Substring(4, 2) + "-" + tBstart.Substring(6, 2); czzy = cznr;
                                        }
                                        else
                                        {
                                            M_Q_sfz_save.startdate = DateTime.Parse(common_file.common_app.cssj);
                                        }
                                        if (tBend.Length > 9)
                                        {
                                            M_Q_sfz_save.enddate = DateTime.Parse(tBend.Substring(0, 4) + "-" + tBend.Substring(4, 2) + "-" + tBend.Substring(6, 2));
                                            cznr = "生成模尾" + tBend.Substring(0, 4) + "-" + tBend.Substring(4, 2) + "-" + tBend.Substring(6, 2); czzy = cznr;
                                        }
                                        else
                                        {
                                            M_Q_sfz_save.enddate = DateTime.Parse(common_file.common_app.cssj);
                                        }
                                        M_Q_sfz_save.department = tBdepart;
                                        cznr = "生成模尾" + tBdepart; czzy = cznr;
                                        if (imageb.Length > 0)
                                        {
                                            M_Q_sfz_save.krxp = imageb;
                                        }
                                        cznr = "获取片"; czzy = cznr;
                                        B_Q_sfz_save.Add(M_Q_sfz_save);
                                        imakrxp = imageb;
                                        cznr    = "保存后"; czzy = cznr;
                                    }
                                    //PictureBox PictureBox_new = new PictureBox();
                                    //PictureBox_new.ImageLocation = Application.StartupPath + @"\ZP.bmp";
                                    //PictureBox_nw_1 = PictureBox_new;
                                }
                            }
                            catch
                            {
                                common_file.common_czjl.add_czjl(common_file.common_app.yydh, common_file.common_app.qymc, common_file.common_app.czy, "检查身份证刷新问题", czzy, cznr, DateTime.Now);
                                common_file.common_app.Message_box_show(common_file.common_app.message_title, "读卡成功了,但转换数据时有问题了,请重新刷卡试试,如不行请重启酒店系统!");
                                CloseComm();
                            }
                            finally
                            {
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        common_file.common_app.Message_box_show(common_file.common_app.message_title, "读证错误,请关闭此窗体,打开重新读证.");
                    }
                }
                return(s_0);
            }