public static void UpdateCustomFields(DataRow rowForm, Guid gID, string sCUSTOM_MODULE, DataTable dtCustomFields)
        {
            if (dtCustomFields.Rows.Count > 0)
            {
                InlineQueryDBManager oQuery = new InlineQueryDBManager();
                oQuery.CommandText = "update " + sCUSTOM_MODULE + "_CSTM" + ControlChars.CrLf;
                int nFieldIndex = 0;
                foreach (DataRow row in dtCustomFields.Rows)
                {

                    string sNAME = TypeConvert.ToString(row["NAME"]).ToUpper();
                    string sCsType = TypeConvert.ToString(row["CsType"]);

                    int nMAX_SIZE = TypeConvert.ToInteger(row["MAX_SIZE"]);
                    if (rowForm.Table.Columns.Contains(sNAME))
                    {
                        if (nFieldIndex == 0)
                            oQuery.CommandText += "   set ";
                        else
                            oQuery.CommandText += "     , ";

                        oQuery.CommandText += sNAME + " = @" + sNAME + ControlChars.CrLf;

                        SqlParameter oParam = new SqlParameter();

                        switch (sCsType)
                        {
                            case "Guid":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.UniqueIdentifier);
                                oParam.Value = TypeConvert.ToGuid(rowForm[sNAME]);
                                break;
                            case "short":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = TypeConvert.ToInteger(rowForm[sNAME]);
                                break;
                            case "Int32":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = TypeConvert.ToInteger(rowForm[sNAME]);
                                break;
                            case "Int64":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = TypeConvert.ToInteger(rowForm[sNAME]);
                                break;
                            case "float":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Float);
                                oParam.Value = TypeConvert.ToFloat(rowForm[sNAME]);
                                break;
                            case "decimal":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Decimal);
                                oParam.Value = TypeConvert.ToDecimal(rowForm[sNAME]);
                                break;
                            case "bool":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Bit);
                                oParam.Value = TypeConvert.ToBoolean(rowForm[sNAME]);
                                break;
                            case "DateTime":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.DateTime);
                                oParam.Value = TypeConvert.ToDateTime(rowForm[sNAME]);
                                break;
                            default:
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.NVarChar, nMAX_SIZE);
                                oParam.Value = TypeConvert.ToString(rowForm[sNAME]);
                                break;
                        }
                        nFieldIndex++;
                    }
                }
                if (nFieldIndex > 0)
                {
                    oQuery.CommandText += " where ID_C = @ID_C" + ControlChars.CrLf;
                    SqlParameter oParamID = new SqlParameter("@ID_C", SqlDbType.UniqueIdentifier);
                    oParamID.Value = gID;
                    oQuery.CommandType = CommandType.Text;
                    oQuery.ExecuteNonQuery(oQuery.CommandText);
                }
            }
        }
        public static void UpdateCustomFields(CRMControl ctlPARENT, Guid gID, string sCUSTOM_MODULE, DataTable dtCustomFields)
        {
            if (dtCustomFields.Rows.Count > 0)
            {
                InlineQueryDBManager oQuery = new InlineQueryDBManager();
                oQuery.CommandText = "update " + sCUSTOM_MODULE + "_CSTM" + ControlChars.CrLf;
                int nFieldIndex = 0;
                foreach (DataRow row in dtCustomFields.Rows)
                {
                    string sNAME = TypeConvert.ToString(row["NAME"]).ToUpper();
                    string sCsType = TypeConvert.ToString(row["CsType"]);

                    int nMAX_SIZE = TypeConvert.ToInteger(row["MAX_SIZE"]);
                    DynamicControl ctlCustomField = new DynamicControl(ctlPARENT, sNAME);

                    if (ctlCustomField.Exists && ctlCustomField.Type != "Literal")
                    {
                        if (nFieldIndex == 0)
                            oQuery.CommandText += "   set ";
                        else
                            oQuery.CommandText += "     , ";

                        oQuery.CommandText += sNAME + " = @" + sNAME + ControlChars.CrLf;

                        DynamicControl ctlCustomField_File = new DynamicControl(ctlPARENT, sNAME + "_File");

                        if (sCsType == "Guid" && ctlCustomField.Type == "HtmlInputHidden" && ctlCustomField_File.Exists)
                        {
                            LoadImage(ctlPARENT, gID, sNAME);
                        }
                        SqlParameter oParam = new SqlParameter();
                        switch (sCsType)
                        {
                            case "Guid":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.UniqueIdentifier);
                                oParam.Value = ctlCustomField.ID;
                                break;
                            case "short":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = ctlCustomField.IntegerValue;
                                break;
                            case "Int32":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = ctlCustomField.IntegerValue;
                                break;
                            case "Int64":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Int);
                                oParam.Value = ctlCustomField.IntegerValue;
                                break;
                            case "float":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Float);
                                oParam.Value = ctlCustomField.FloatValue;
                                break;
                            case "decimal":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Decimal);
                                oParam.Value = ctlCustomField.DecimalValue;
                                break;
                            case "bool":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.Bit);
                                oParam.Value = ctlCustomField.Checked;
                                break;
                            case "DateTime":
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.DateTime);
                                oParam.Value = ctlCustomField.DateValue;
                                break;
                            default:
                                oParam = new SqlParameter("@" + sNAME, SqlDbType.NVarChar, nMAX_SIZE);
                                oParam.Value = ctlCustomField.Text;
                                break;
                        }
                        nFieldIndex++;
                    }
                }
                if (nFieldIndex > 0)
                {
                    oQuery.CommandText += " where ID_C = @ID_C" + ControlChars.CrLf;
                    SqlParameter oParamID = new SqlParameter("@ID_C", SqlDbType.UniqueIdentifier);
                    oParamID.Value = gID;
                    oQuery.CommandType = CommandType.Text;
                    oQuery.ExecuteNonQuery(oQuery.CommandText);
                }
            }
        }