Exemple #1
0
 public static List <ReportTemplete> ListAllTempleteWithType(int type)
 {
     try
     {
         DbManager      dm    = DbManager.Ins;
         MySqlParameter _type = new MySqlParameter("_type", MySqlDbType.Int32);
         _type.Value = type;
         MySqlParameter[]      pars = new MySqlParameter[] { _type };
         DataTable             dt   = dm.ExecuteProcQuery("ReportTemplete_ListAllWithType", pars);
         List <ReportTemplete> rts  = new List <ReportTemplete>();
         foreach (DataRow dr in dt.Rows)
         {
             ReportTemplete rt = new ReportTemplete();
             rt.Id        = (int)dr["id"];
             rt.Name      = (string)dr["name"];
             rt.Induction = (string)dr["induction"];
             rts.Add(rt);
         }
         return(rts);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #2
0
 private void bu_add_Click(object sender, EventArgs e)
 {
     if (tb_name.Text.Length != 0 && tb_path.Text.Length != 0)
     {
         byte[] buffer = FileToByte(tb_path.Text);
         if (buffer != null)
         {
             ReportTemplete rt = new ReportTemplete();
             rt.Type      = cb_type.SelectedIndex;
             rt.Name      = tb_name.Text;
             rt.Induction = tb_induction.Text;
             rt.OwnerId   = 0;
             rt.Raw       = buffer;
             bool res = DBReportTempleteAdapter.Insert(rt);
             if (res)
             {
                 RefreshList();
                 MessageBox.Show("添加成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("无法读取" + tb_path.Text, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else
     {
         MessageBox.Show("请您填写名称和文件路径", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Exemple #3
0
 public static bool Insert(ReportTemplete rt)
 {
     try
     {
         DbManager        dm   = DbManager.Ins;
         MySqlParameter[] pars = MakeInsertParameter(rt);
         DataTable        dt   = dm.ExecuteProcQuery("ReportTemplete_Insert", pars);
         rt.Id = (int)dt.Rows[0][0];
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #4
0
        private static MySqlParameter[] MakeInsertParameter(ReportTemplete rt)
        {
            MySqlParameter _ownerid = new MySqlParameter("_ownerid", MySqlDbType.Int32);

            _ownerid.Value = rt.OwnerId;
            MySqlParameter _type = new MySqlParameter("_type", MySqlDbType.Int32);

            _type.Value = rt.Type;
            MySqlParameter _name = new MySqlParameter("_name", MySqlDbType.String);

            _name.Value = rt.Name;
            MySqlParameter _induction = new MySqlParameter("_induction", MySqlDbType.String);

            _induction.Value = rt.Induction;
            MySqlParameter _raw = new MySqlParameter("_raw", MySqlDbType.LongBlob);

            _raw.Value = rt.Raw;
            return(new MySqlParameter[] { _ownerid, _type, _name, _induction, _raw });
        }