Esempio n. 1
0
        public static void DeleteField(string CompanyID, string ID, string FieldName, string TableType)
        {
            DataHelper.ExecuteQuerys("ALTER TABLE " + CompanyDAL.GetTableName(CompanyID, TableType) + " Drop column " + FieldName);
            FieldDAL.DeleteField(ID);
            string where = "CompanyID='{0}' and TableType ='{1}'";
            DataSet ds = FieldDAL.GetFieldList(string.Format(where, CompanyID, TableType));

            HttpContext.Current.Cache[Tools.GetCashName(CompanyID, TableType)] = ds;
        }
Esempio n. 2
0
        public static void InsertField(string FieldName, string FName, string CompanyID, string TableType, string FieldType, string FieldLength, string Misk, string IsDispaly)
        {
            if (FieldLength.Trim() == "")
            {
                FieldLength = "300";
            }
            FieldDAL.InsertField(FieldName, FName, CompanyID, TableType, FieldType, FieldLength, Misk, IsDispaly);
            string tableName = CompanyDAL.GetTableName(CompanyID, TableType);

            DataHelper.ExecuteQuerys("ALTER TABLE " + tableName + " ADD " + FieldName + " NVARCHAR(" + FieldLength + ") NULL");
            string where = "CompanyID='{0}' and TableType ='{1}'";
            DataSet ds = FieldDAL.GetFieldList(string.Format(where, CompanyID, TableType));

            HttpContext.Current.Cache[Tools.GetCashName(CompanyID, TableType)] = ds;
        }
Esempio n. 3
0
        public static void UpdateTbKey(string CompanyID, string tableType, string newKey)
        {
            DataSet   ds        = HttpContext.Current.Cache[Tools.GetCashName(CompanyID, tableType)] as DataSet;
            string    tableName = CompanyDAL.GetTableName(CompanyID, tableType);
            DataTable dt        = ds.Tables[0];
            string    newKeyID  = dt.Select("FieldName='" + newKey + "'")[0]["ID"].ToString();

            DataRow[] drsTbkey = dt.Select("FieldName='tbKey'");
            if (drsTbkey.Length == 0)
            {
                DataHelper.ExecuteQuerys(string.Format(" EXEC sp_rename '{0}.{1}', 'tbKey', 'column' ", tableName, newKey));
                FieldBLL.UpdateField(newKeyID, "tbKey", CompanyID, tableType);
            }
            else
            {
                string oldKeyID     = drsTbkey[0]["ID"].ToString();
                string oldFieldName = "tb_" + DateTime.Now.Ticks.ToString();
                DataHelper.ExecuteQuerysArray(new string[] { string.Format("EXEC sp_rename '{0}.tbKey', '{1}', 'column' ", tableName, oldFieldName), string.Format("EXEC sp_rename '{0}.{1}', 'tbKey', 'column' ", tableName, newKey) });
                FieldBLL.UpdateField(oldKeyID, oldFieldName, CompanyID, tableType);
                FieldBLL.UpdateField(newKeyID, "tbKey", CompanyID, tableType);
            }
        }