Ejemplo n.º 1
0
 /// <summary>Hàm lấy Object từ dữ liệu kiểu chuỗi.
 /// </summary>
 public static object GetObjectFromPLString(string data, FWPLDataType dataType)
 {
     switch (dataType)
     {
         case FWPLDataType.BOOL:
             if (data == String.Empty)
                 return null;
             else if (data == "Y")
                 return true;
             else if (data == "N")
                 return false;
             break;
         case FWPLDataType.DOUBLE_NUMBER:
             return double.Parse(data);
         case FWPLDataType.INT_NUMBER:
             return long.Parse(data);
         case FWPLDataType.TEXT:
             return data;
         case FWPLDataType.DISPLAY_DATE:
             return HelpDateExt02.ParseDisplayDate(data);
         case FWPLDataType.LONG_TIME:
             return HelpDateExt02.ParseLongTime(data);
         case FWPLDataType.SHORT_TIME:
             return HelpDateExt02.ParseShortTime(data);
         default:
             break;
     }
     return null;
 }
Ejemplo n.º 2
0
 /// <summary>Hàm lấy chuỗi tương ứng dataType để lưu
 /// </summary>
 public static string GetPLStringFromObject(object data, FWPLDataType dataType)
 {
     if (data == null) return "";
     switch (dataType)
     {
         case FWPLDataType.BOOL:
             if (data.ToString()=="True" || data.ToString() == "Y" )
                 return "Y";
             else if (data.ToString() == "False" || data.ToString() == "N")
                 return "N";
             break;
         case FWPLDataType.DISPLAY_DATE:
             return HelpDateExt02.ToDisplayDateString((DateTime)data);
         case FWPLDataType.DOUBLE_NUMBER:
             return "" + data;
         case FWPLDataType.TEXT:
             return data.ToString();
         case FWPLDataType.SHORT_TIME:
             return HelpDateExt02.ToShortTimeString((DateTime)data);
         default:
             break;
     }
     return "";
 }
Ejemplo n.º 3
0
        public static bool SetThamSo(string TenThamSo, object GiaTri, FWPLDataType dataType)
        {
            try
            {
                DatabaseFB db = DABase.getDatabase();
                DbCommand dbUpdate = null;
                if (TonTaiThamSo(TenThamSo))
                {
                    dbUpdate = db.GetSQLStringCommand("update fw_tham_so_ung_dung set gia_tri=@giatri where ten_tham_so=@thamso");
                    db.AddInParameter(dbUpdate, "@thamso", DbType.String, TenThamSo);
                    db.AddInParameter(dbUpdate, "@giatri", DbType.String, HelpMultiDataTypeField.GetPLStringFromObject(GiaTri, dataType));
                }
                else
                    return false;

                db.ExecuteNonQuery(dbUpdate);
                return true;
            }
            catch (Exception ex)
            {
                PLException.AddException(ex);
                return false;
            }
        }