Exemplo n.º 1
0
 public DataTable Save(string WorkSet_Id, DataTable Data, List <MyParameter> sqlParameters)
 {
     try
     {
         if (sqlParameters == null)
         {
             sqlParameters = new List <MyParameter>();
         }
         Sys_WorkSet wkCmd = PreparWorkSet(WorkSet_Id);
         if (wkCmd != null)
         {
             if (!string.IsNullOrEmpty(wkCmd.WorkSet_Connection))
             {
                 db.ConnectionString = wkCmd.WorkSet_Connection;
             }
             db.UpdateDataTable(Data, wkCmd.WorkSet_Insert, wkCmd.WorkSet_Update, wkCmd.WorkSet_Delete, PreparParameters(sqlParameters), PreparParameters(sqlParameters), PreparParameters(sqlParameters));
             return(null);
         }
         throw new ArgumentNullException(WorkSet_Id);
     }
     catch
     {
         return(Data);
         //throw new Exception(string.Concat(WorkSet_Id, "\r\n", ex.Message, "\r\n", sqlParameters.ToJson()));
     }
     finally
     {
         db.ConnectionString = baseConn;
     }
 }
Exemplo n.º 2
0
 public DataTable Open(string WorkSet_Id, List <MyParameter> sqlParameters = null)
 {
     try
     {
         if (string.IsNullOrEmpty(WorkSet_Id))
         {
             return(null);
         }
         if (sqlParameters == null)
         {
             sqlParameters = new List <MyParameter>();
         }
         Sys_WorkSet wkCmd = PreparWorkSet(WorkSet_Id);
         if (wkCmd != null)
         {
             string ReadSql = wkCmd.WorkSet_Select;
             if (!string.IsNullOrEmpty(ReadSql))
             {
                 if (!string.IsNullOrEmpty(wkCmd.WorkSet_Connection))
                 {
                     db.ConnectionString = wkCmd.WorkSet_Connection;
                 }
                 DataTable rdt = db.ExecuteDataTable(ReadSql, PreparParameters(sqlParameters));
                 return(rdt);
             }
             else
             {
                 throw new ArgumentNullException(WorkSet_Id + ".WorkSet_Select");
             }
         }
         else
         {
             throw new ArgumentNullException(WorkSet_Id);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         db.ConnectionString = baseConn;
     }
 }
Exemplo n.º 3
0
 public virtual void Design()
 {
     try
     {
         if (FocusedChart() != null)
         {
             ChartControl chartControl = FocusedChart();
             Sys_WorkSet  sys_WorkSet  = WorkSetList.Find(w => w.WorkSet_Grid == chartControl.Name);
             if (sys_WorkSet == null)
             {
                 return;
             }
             List <MyParameter> mps = new List <MyParameter>();
             mps = InitializeBind(sys_WorkSet.WorkSet_Id, true);
             DataTable dt = BaseService.Open(sys_WorkSet.WorkSet_Id, mps);
             chartControl.DataSource = dt;
             ChartDesigner chartDesigner = new ChartDesigner(chartControl);
             if (chartDesigner.ShowDialog().Equals(DialogResult.OK))
             {
                 MemoryStream memoryStream = new MemoryStream();
                 chartControl.SaveToStream(memoryStream);
                 Sys_Chart sys_Chart = new Sys_Chart();
                 sys_Chart.Chart_Name    = chartControl.Name;
                 sys_Chart.Chart_Nick    = chartControl.Name;
                 sys_Chart.Chart_Bytes   = memoryStream.ToArray();
                 sys_Chart.Chart_WorkSet = sys_WorkSet.WorkSet_Id;
                 sys_Chart.IsEnabled     = true;
                 sys_Chart.IsDelete      = false;
                 BaseService.Execute("SystemChart_Save", sys_Chart);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 取得字段绑定的值
        /// </summary>
        /// <param name="sys_Bind"></param>
        /// <returns></returns>
        private object InitializeParameter(Sys_Bind sys_Bind)
        {
            object val = null;
            //if (sys_Bind.Bind_Field.StartsWith("val:"))
            //{
            //    val = sys_Bind.Bind_Field.Remove(0, 4);
            //}

            object control = sys_Bind.Bind_Control;

            //没有绑定过控件 绑定Sys_Bind到相应控件
            if (control == null)
            {
                if (sys_Bind.Bind_Field.IndexOf(".") > 0)
                {
                    string    gd           = sys_Bind.Bind_Field.Substring(0, sys_Bind.Bind_Field.IndexOf("."));
                    Control[] bindControls = this.Controls.Find(gd, true);
                    if (bindControls.Length > 0)
                    {
                        if (bindControls[0].GetType().Equals(typeof(GridControl)))
                        {
                            GridControl tgd  = (GridControl)bindControls[0];
                            GridView    tabv = (GridView)tgd.MainView;
                            string      col  = sys_Bind.Bind_Field.Substring(sys_Bind.Bind_Field.IndexOf(".") + 1);
                            sys_Bind.Bind_Control = tabv.Columns[col];
                        }
                    }
                }
                else
                {
                    //优先绑定Edit控件
                    Control[] bindControls = this.Controls.Find(sys_Bind.Bind_Field, true);
                    if (bindControls.Length > 0)
                    {
                        sys_Bind.Bind_Control = bindControls[0];
                    }
                    //如果没找到则绑定数据列
                    //判断传入的如果是Name 自动转为 Id
                    Sys_WorkSet twk = WorkSetList.Find(w => w.WorkSet_Id.Equals(sys_Bind.Bind_WorkSet));
                    if (twk != null && twk.WorkSet_Control != null && sys_Bind.Bind_Control == null)
                    {
                        GridView gv = (GridView)((GridControl)twk.WorkSet_Control).MainView;
                        sys_Bind.Bind_Control = gv.Columns[sys_Bind.Bind_Field];
                    }
                }
                control = sys_Bind.Bind_Control;
            }                    //绑定控件之后
            if (control != null)
            {
                object obj = null;
                //如果控件存在 且不是表格列 则用反射获取控件的值
                if (control.GetType() != typeof(GridColumn))
                {
                    //如果指定了属性则直接从属性里取
                    if (!string.IsNullOrEmpty(sys_Bind.Bind_Property))
                    {
                        obj = GetValue((Control)control, sys_Bind.Bind_Property);
                    }
                    //否则取默认的EditValue 若为空再取Text
                    else
                    {
                        obj = GetValue((Control)control, "EditValue");
                        if (obj == null)
                        {
                            obj = GetValue((Control)control, "Text");
                        }
                    }
                }
                //如果控件存在且是表格列 则取单元格中值
                else
                {
                    GridColumn bgc = (GridColumn)control;
                    if (bgc.View.FocusedRowHandle >= 0 || bgc.View.IsNewItemRow(bgc.View.FocusedRowHandle))
                    {
                        obj = bgc.View.GetFocusedRowCellValue(bgc);
                    }
                }
                //obj从DBNull转为null
                if (obj == DBNull.Value || string.IsNullOrEmpty(obj.ToStringEx()))
                {
                    obj = null;
                }
                val = obj;
            }
            return(val);
        }
Exemplo n.º 5
0
        public int Execute(string WorkSet_Id, List <MyParameter> sqlParameters = null, string CRUD = "R")
        {
            try
            {
                if (sqlParameters == null)
                {
                    sqlParameters = new List <MyParameter>();
                }
                if (string.IsNullOrEmpty(WorkSet_Id))
                {
                    return(0);
                }
                Sys_WorkSet wkCmd = PreparWorkSet(WorkSet_Id);
                if (wkCmd != null)
                {
                    string sqlCRUD = "";
                    switch (CRUD.ToUpper())
                    {
                    case "I":
                        sqlCRUD = wkCmd.WorkSet_Insert;
                        break;

                    case "C":
                        sqlCRUD = wkCmd.WorkSet_Insert;
                        break;

                    case "R":
                        sqlCRUD = wkCmd.WorkSet_Select;
                        break;

                    case "U":
                        sqlCRUD = wkCmd.WorkSet_Update;
                        break;

                    case "D":
                        sqlCRUD = wkCmd.WorkSet_Delete;
                        break;

                    default:
                        break;
                    }
                    if (!string.IsNullOrEmpty(sqlCRUD))
                    {
                        if (!string.IsNullOrEmpty(wkCmd.WorkSet_Connection))
                        {
                            db.ConnectionString = wkCmd.WorkSet_Connection;
                        }
                        int rtn = db.ExecuteNonQuery(sqlCRUD, PreparParameters(sqlParameters));
                        return(rtn);
                    }
                }
                throw new ArgumentNullException(WorkSet_Id);
            }
            catch (FaultException ex)
            {
                throw new Exception(string.Concat(WorkSet_Id, "\r\n", ex.Message, "\r\n", sqlParameters.ToJson()));
            }
            finally
            {
                db.ConnectionString = baseConn;
            }
        }