public string PersonerInfo(string CardSn)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                if (ConfigurationManager.AppSettings["CofeePosCardType"] == "1")
                {
                    CardSn = (100000000 + DeCode1(CardSn)).ToString().Remove(0, 1);
                }
                string ConnString = ConfigurationManager.AppSettings["cfsf"];
                nrWebClass.DAL.SqlDbHelper dal       = new nrWebClass.DAL.SqlDbHelper(ConnString);
                SqlParameter[]             paramters = new SqlParameter[] {
                    new SqlParameter("@CardSn", int.Parse(CardSn))
                };
                LiLanzDAL dal2 = new LiLanzDAL();

                using (IDataReader reader = dal.ExecuteReader(@"select t2.DeptName,CardSnr,CustomerName,
t1.CustomerNo,t2.DeptNo,t1.AccountNo,isnull(t1.AccStat,0),isnull(t1.CardStat,0),t1.sex
from tb_Customer_coffee as t1
inner join tb_Department as t2 on t1.DeptNo=t2.DeptNo where CardSnr=@CardSn", CommandType.Text, paramters))
                {
                    if (reader.Read())
                    {
                        if (reader[6].ToString() == "0" && reader[7].ToString() == "0")
                        {
                            int isLeave = 0;
                            if (IsLeave(reader[5].ToString()))
                            {
                                isLeave = 1;
                            }

                            sb.Append("<?xml version=\"1.0\" encoding=\"gb2312\"?>");
                            sb.Append(String.Format("<CardInfo Dept=\"{0}\" CardNo=\"{1}\" Cname=\"{2}\" PersonSn=\"{3}\" DeptNo=\"{4}\" AccountNo=\"{5}\" Sex=\"{6}\" isLeave=\"{7}\">",
                                                    reader[0], CardSnFill(reader[1].ToString()), reader[2], reader[3], reader[4], reader[5], reader["sex"], isLeave));
                            sb.Append("</CardInfo>");
                        }
                        //SqlParameter[] paramters2 = new SqlParameter[]{
                        //  new SqlParameter("@AccountNo", int.Parse(reader[5].ToString()))
                        //};
                        //if (dal2.ExecuteScalar("select 1 from cy_t_coffeeStopSign where AccountNo=@AccountNo",
                        //    CommandType.Text, paramters2) != null)
                        //    sb.Length = 0;
                    }
                    reader.Dispose();
                }
            }
            catch (Exception ex)
            {
                sb.Append(ex.ToString());
            }
            return(sb.ToString());
        }
Example #2
0
        public string UpdateLoadData(string xml, string dayStart, string dayEnd)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(List <CheckTime>));
            // A FileStream is needed to read the XML document.
            XmlReader        reader      = XmlReader.Create(new System.IO.StringReader(xml));
            List <CheckTime> AddressList = (List <CheckTime>)serializer.Deserialize(reader);
            int       rowCount           = 0;
            LiLanzDAL dal = new LiLanzDAL();

            try
            {
                string         sql       = "DELETE FROM dbo.kq_T_rydkmx WHERE ChecktimeStart>=@start and ChecktimeStart<@end";
                SqlParameter[] paramters = new SqlParameter[] {
                    new SqlParameter("@start", DateTime.Parse(dayStart)),
                    new SqlParameter("@end", DateTime.Parse(dayEnd).AddDays(1))
                };
                dal.ExecuteNonQuery(sql, CommandType.Text, paramters);
                foreach (CheckTime ch in AddressList)
                {
                    if (ch.BadgeNumber.Length < 6)
                    {
                        ch.BadgeNumber = "000000".Substring(0, 6 - ch.BadgeNumber.Length) + ch.BadgeNumber;
                    }

                    sql       = @" INSERT INTO dbo.kq_T_rydkmx
                (BadgeNumber, days, statu, ChecktimeStart, ChecktimeEnd, LateMinutes,EarlyMinutes) VALUES  
                (@BadgeNumber, @days, @statu, @ChecktimeStart, @ChecktimeEnd, @LateMinutes, @EarlyMinutes);";
                    paramters = new SqlParameter[] {
                        new SqlParameter("@BadgeNumber", ch.BadgeNumber),
                        new SqlParameter("@days", Decimal.Parse(ch.days)),
                        new SqlParameter("@statu", int.Parse(ch.statu)),
                        new SqlParameter("@ChecktimeStart", DateTime.Parse(ch.ChecktimeStart)),
                        new SqlParameter("@ChecktimeEnd", DateTime.Parse(ch.ChecktimeEnd)),
                        new SqlParameter("@LateMinutes", int.Parse(ch.LateMinutes)),
                        new SqlParameter("@EarlyMinutes", int.Parse(ch.EarlyMinutes))
                    };

                    if (dal.ExecuteNonQuery(sql, CommandType.Text, paramters) > 0)
                    {
                        rowCount++;
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }

            return(rowCount.ToString());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="AccountNo"></param>
        /// <returns></returns>
        private bool IsLeave(string AccountNo)
        {
            String sql = String.Format("SELECT 1 FROM cy_t_coffeeStopSign WHERE AccountNo = '{0}'", AccountNo);

            //Log.Info(sql);
            nrWebClass.LiLanzDAL dal = new LiLanzDAL();
            Object rel = dal.ExecuteScalar(sql);

            //Log.Info(rel.GetType().ToString());
            if (rel == null)
            {
                return(false);
            }
            return(true);
        }