Example #1
0
        /// <summary>
        /// 单独查询
        /// </summary>
        /// <param name="name">姓名</param>
        /// <returns></returns>
        public List <BloodUser> SelectUserByName(string name)
        {
            List <BloodUser> list = null;

            cmd.CommandText = "select id 编号,useblood_name 用血者,refund_date 报销时间  from [dbo].[blood_refund_record] where useblood_name=@name";
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@name", name);
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                list = new List <BloodUser>();
                while (dr.Read())
                {
                    BloodUser b = new BloodUser();
                    b.HisID       = dr["编号"].ToString();
                    b.Name        = dr["用血者"].ToString();
                    b.Refund_date = DateTime.Parse(dr["报销时间"].ToString());
                    list.Add(b);
                }
            }
            cmd.Dispose();
            conn.Close();
            return(list);
        }
Example #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="user"></param>
        public void UpdataVoucherFile(BloodUser user, string field)
        {
            StringBuilder sb = new StringBuilder("update voucherFile set ");

            sb.Append(field + "=@field ,");
            sb.Append("done_settlement=@done_settlement ");
            sb.Append(" where HisID=@hisID");

            cmd.CommandText = sb.ToString();
            cmd.Parameters.Clear();

            Type         t      = user.GetType();
            PropertyInfo piName = t.GetProperty(field);
            //给Name属性赋值
            string text = piName.GetValue(user).ToString();

            cmd.Parameters.AddWithValue("@field", text);
            cmd.Parameters.AddWithValue("@done_settlement", user.done_settlement);
            cmd.Parameters.AddWithValue("@hisID", user.HisID);

            conn.Open();
            cmd.ExecuteNonQuery();//执行SQL语句,并返回受影响的行
            cmd.Dispose();
            conn.Close();
        }
Example #3
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="user"></param>
        public void InsertVoucherFile(BloodUser user)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("insert into voucherFile values(");
            sb.Append("@userIDcard,@Devotee,@HisID,@regdate,@Hp_settlement,@Pre_settlement,@done_settlement,@Voucher)");
            cmd.CommandText = sb.ToString();
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@userIDcard", string.IsNullOrEmpty(user.userIDcard) ? "" : user.userIDcard);
            cmd.Parameters.AddWithValue("@Devotee", string.IsNullOrEmpty(user.Devotee) ? "" : user.Devotee);
            cmd.Parameters.AddWithValue("@HisID", string.IsNullOrEmpty(user.HisID) ? "" : user.HisID);
            cmd.Parameters.AddWithValue("@regdate", DateTime.Now);
            cmd.Parameters.AddWithValue("@Hp_settlement", string.IsNullOrEmpty(user.Hp_settlement) ? "" : user.Hp_settlement);
            cmd.Parameters.AddWithValue("@Pre_settlement", string.IsNullOrEmpty(user.Pre_settlement) ? "" : user.Pre_settlement);
            cmd.Parameters.AddWithValue("@done_settlement", string.IsNullOrEmpty(user.done_settlement) ? "" : user.done_settlement);
            cmd.Parameters.AddWithValue("@Voucher", string.IsNullOrEmpty(user.Voucher) ? "" : user.Voucher);
            conn.Open();
            cmd.ExecuteNonQuery();//执行SQL语句,并返回受影响的行
            cmd.Dispose();
            conn.Close();
        }
Example #4
0
        private void GetFiles()
        {
            try
            {
                string baseDirectory = this.textBox1.Text;
                if (!string.IsNullOrEmpty(baseDirectory))
                {
                    var directory = Directory.GetDirectories(baseDirectory);
                    foreach (var dir in directory)
                    {
                        string entrant = dir.Substring(dir.LastIndexOf('\\') + 1);//录入人
                        this.textBox3.Text = entrant;
                        var files = Directory.GetFiles(dir);
                        this.entrantCount.Text = files.Length.ToString();
                        int processedCount = 0;
                        this.ProcessedCount.Text = processedCount.ToString();
                        foreach (var file in files)
                        {
                            FileInfo fileInfo         = new FileInfo(file);
                            string   filename         = fileInfo.Name;
                            string   fileNameNoSuffix = filename.Remove(filename.IndexOf('.'));
                            var      arrayofname      = fileNameNoSuffix.Split('_');
                            var      bmp = ReadImageFile(fileInfo.FullName);
                            if (bmp != null)
                            {
                                List <BloodUser> list = dbf.SelectUserByName(arrayofname[0]);
                                if (list != null)
                                {
                                    BloodUser user = null;
                                    //判断图片的报销日期
                                    if (!string.IsNullOrWhiteSpace(arrayofname[2]))
                                    {
                                        DateTime refund_date = StringToDate(arrayofname[2]);
                                        user = list.FirstOrDefault(x => x.Refund_date == refund_date);
                                        if (user == null)
                                        {
                                            user = list.FirstOrDefault();
                                        }
                                    }
                                    else
                                    {
                                        user = list[0];
                                    }
                                    if (user != null)
                                    {
                                        string his_ID  = user.HisID;
                                        string oldName = filename;
                                        string prefix  = NameConvert(arrayofname[1]);
                                        string newName = prefix + oldName;
                                        #region 保存文件
                                        SavePic(bmp, prefix + oldName, his_ID, entrant);
                                        #endregion
                                        #region 保存数据库
                                        Type         t      = user.GetType();
                                        PropertyInfo piName = t.GetProperty(prefix);
                                        //给对应字段设置图片地址
                                        piName.SetValue(user, "\\" + prefix + oldName, null);

                                        user.done_settlement = entrant;
                                        //判断voucherFile是否存在记录
                                        if (dbf.ExistVoucherFile(user.HisID))
                                        {
                                            dbf.UpdataVoucherFile(user, prefix);
                                        }
                                        else
                                        {
                                            dbf.InsertVoucherFile(user);
                                        }
                                        #endregion
                                        //删除原文件
                                        fileInfo.Delete();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("未查询到图片姓名:" + arrayofname[0]);
                                }
                            }
                            else
                            {
                                MessageBox.Show("图片读取失败,请检查路径");
                            }

                            #region 更新已完成数量
                            processedCount++;
                            this.ProcessedCount.Text = processedCount.ToString();
                            #endregion
                        }
                    }
                }
                MessageBox.Show("保存完成");
            }
            catch (Exception e)
            {
            }
        }