/// <summary>
 /// 获取当前用户状态,用于操作日志
 /// </summary>
 /// <returns>操作日志模型</returns>
 public Model_操作日志 GetOperateLog()
 {
     Model_操作日志 mr = new Model_操作日志();
     mr.用户名 = CommonInfo.用户名;
     mr.姓名 = CommonInfo.真实姓名;
     mr.日期 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     return mr;
 }
 public Page_Two_系统管理()
 {
     InitializeComponent();
     SubscribeToEvent();
     LoadPage();
     VisibilityData();
     mrc = vmr.GetOperateLog();
 }
 public Page_修改用户(int id)
 {
     InitializeComponent();
     this.id = id;
     InitComboBox();
     InitData(id);
     _mr = vmr.GetOperateLog();
 }
 public Page_Two_报表管理()
 {
     InitializeComponent();
     SubscribeToEvent();
     for (int i = 1; i <= 3; i++)
     {
         Label lb = FindName("Label_编制单位" + i) as Label;
         lb.Content = "编制单位:" + CommonInfo.制表单位;
     }
     mr = vm.GetOperateLog();
     FreshComboBox();
 }
 public List<Model_操作日志> GetData(string start, string end)
 {
     List<Model_操作日志> list = new List<Model_操作日志>();
     string sql = "select strftime(op_time),username,realname,log from " + DBTablesName.T_RECORD + " where op_time between '"
         + start + "' and '" + end + "'";
     DataTable dt = new DataTable();
     dt = db.Query(sql).Tables[0];
     int rowid = 1;
     foreach (DataRow d in dt.Rows)
     {
         Model_操作日志 m = new Model_操作日志();
         m.序号 = rowid;
         m.日期 = d[0].ToString();
         m.用户名 = d[1].ToString();
         m.姓名 = d[2].ToString();
         m.日志 = d[3].ToString();
         rowid++;
         list.Add(m);
     }
     return list;
 }
 /// <summary>
 /// 将用户访问插入到日志表中
 /// </summary>
 /// <param name="m"></param>
 public void Insert(Model_操作日志 m)
 {
     List<Model_操作日志> list = new List<Model_操作日志>();
     list.Add(m);
     db.InsertPackage("t_record", list.OfType<object>().ToList());
 }
 public Page_Two_快捷界面()
 {
     InitializeComponent();
     mr = vmr.GetOperateLog();
 }
        private void Button_登陆_Click(object sender, RoutedEventArgs e)
        {
            if (!vsy.GetRunningFlag())
            {
                TextBlock_登陆警告信息.Text = "出于安全考虑,您无法进入系统,详细请联系开发商!";
            #if (!DEBUG)
                return;
            #endif
            }
            string bookname = ComboBox_账套.Text.ToString();
            string  id = ComboBox_账套.SelectedValue.ToString();
            CommonInfo.账薄号 = id;
            CommonInfo.账套信息 = bookname;
            string UserName = TextBox_登陆用户名.Text.Trim();
            string Password = Secure.TranslatePassword(PasswordBox_登陆密码.SecurePassword);

            if (vm.ValidateAccount(UserName,Password))
            {
                Model.DataGrid.Model_用户 m = new Model.DataGrid.Model_用户();
                m = vm.GetUserInfo(UserName);
                CommonInfo.真实姓名 = m.真实姓名;
                CommonInfo.用户名 = UserName;
                CommonInfo.用户权限 = m.用户权限;
                CommonInfo.权限值 = m.权限值;
                CommonInfo.登录密码 = Password;
                CommonInfo.制表单位 = xr.ReadXML("单位");
                //先记录一些信息
                Model_操作日志 mr = new Model_操作日志();
                mr = vmr.GetOperateLog();

                if (ComboBox_账套.SelectedIndex==0)
                {
                    if (m.权限值 >= 2)
                    {
                        Win_账套页面 w = new Win_账套页面(this.Left, this.Top);
                        w.Show();
                        this.Close();
                    }
                    else
                    {
                        TextBlock_登陆警告信息.Text = "您的权限不够,无法新建账套!";
                        return;
                    }
                }
                else
                {
                    CommonInfo.制度索引 = vmb.GetStandardIndex();
                    CommonInfo.是否初始化年初数 = new ViewModel_年初金额().IsSaved();
                    CommonInfo.当前期 = vmb.GetPeriod();
                    CommonInfo.年 = vmb.GetYear();
                    //这里写日志信息
                    mr.日志 = "登录了账套:" + bookname;
                    vmr.Insert(mr);

                    xw.WriteXML("账套信息", bookname);
                    MainWindow mw = new MainWindow();
                    mw.Show();
                    this.Close();
                }
            }
            else
            {
                TextBlock_登陆警告信息.Text = "账号或密码错误。";
            }
        }
        private void Button_创建_Click(object sender, RoutedEventArgs e)
        {
            if (!Validate())  //校验不成功
            {
                return;
            }
            List<Model.DataGrid.Model_账套> lm = new List<Model.DataGrid.Model_账套>();
            Model.DataGrid.Model_账套 m = new Model.DataGrid.Model_账套();
            m.ID = DateTime.Now.ToString("yyyyMMddHHmmss");
            CommonInfo.账薄号 = m.ID;
            CommonInfo.当前期 = Convert.ToInt32(TextBox_期.Text.Trim());
            m.账套名称 = TextBox_账套名称.Text.Trim();
            m.单位名称 = TextBox_公司.Text.Trim();
            m.启用期间 = TextBox_year.Text + "年" + TextBox_期.Text + "期";
            m.创建时间 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            m.会计制度 = ComboBox_制度.Text.Trim();
            m.制度索引 = ComboBox_制度.SelectedIndex;
            m.当前期 = Convert.ToInt32(TextBox_期.Text.Trim());
            CommonInfo.年 = TextBox_year.Text;

            CommonInfo.制度索引 = m.制度索引.ToString();
            CommonInfo.制表单位 = m.单位名称;
            lm.Add(m);

            //修改下次启动时帐套的显示
            xw.WriteXML("账套信息", m.账套名称);
            xw.WriteXML("单位",TextBox_公司.Text.Trim());

            //数据创建步骤
            //1.创建账套
            bool flag1 = new ViewModel_Books().Insert(lm);
            if (!flag1)
            {
                MessageBoxCommon.Show("创建帐套时候发生异常,请联系开发商解决问题!");
                return;
            }
            //2.为账套新建初始年初数
            new ViewModel_年初金额().Insert(m.ID);
            Model_操作日志 mr = new Model_操作日志();
            ViewModel_操作日志 vmr = new ViewModel_操作日志();
            mr = vmr.GetOperateLog();
            mr.日志 = "创建了账套:" + m.账套名称;
            vmr.Insert(mr);
            //调整至主页面
            CommonInfo.账套信息 = m.账套名称;
            MainWindow mw = new MainWindow();
            mw.Show();
            this.Close();
        }