예제 #1
0
 public static void Select_AT_CodeMap(AT_CodeMap_Bean Bean, ref StringBuilder sb, bool isReset = false)
 {
     if (isReset)
     {
         sb.Clear();
     }
     sb.AppendLine(" select TabName , FldName , Code , CodeCName , SortFld , NotShowFlag , LastChgComp , LastChgID , LastChgDate ");
     sb.AppendLine(" from AT_CodeMap ");
     sb.AppendLine(" where 1=1 ");
     if (!string.IsNullOrEmpty(Bean.TabName))
     {
         sb.AppendLine(" and TabName=").AppendFormat("@TabName", Bean.TabName);
     }
     if (!string.IsNullOrEmpty(Bean.FldName))
     {
         sb.AppendLine(" and FldName=").AppendFormat("@FldName", Bean.FldName);
     }
 }
예제 #2
0
    /// <summary>
    /// 取得DB資料
    /// 個人班表
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool Select_AT_CodeMap(AT_CodeMap_Model model, out List <AT_CodeMap_Bean> datas, out string msg)
    {
        bool result = false;

        msg   = "";
        datas = new List <AT_CodeMap_Bean>();
        try
        {
            using (var conn = new SqlConnection()
            {
                ConnectionString = DbHelper.getConnectionStrings(_attendantDBName).ConnectionString
            })
            {
                AT_CodeMap_Bean dataBean = new AT_CodeMap_Bean()
                {
                    TabName = model.TabName,
                    FldName = model.FldName
                };
                StringBuilder sb = new StringBuilder();
                SqlCommand.Select_AT_CodeMap(dataBean, ref sb, true);
                try
                {
                    datas = conn.Query <AT_CodeMap_Bean>(sb.ToString(), dataBean).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
                if (datas == null)
                {
                    throw new Exception("查無資料!");
                }
            }
            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }