コード例 #1
0
        public System.Data.SqlClient.SqlCommand getDeleteCommand()
        {
            System.Data.SqlClient.SqlCommand v_Cmd = new System.Data.SqlClient.SqlCommand();
            System.Data.DataColumn v_Column = default(System.Data.DataColumn);
            System.Data.DataRow v_Row = default(System.Data.DataRow);
            System.Data.SqlClient.SqlParameter v_Para = default(System.Data.SqlClient.SqlParameter);

            v_Row = m_ds.Tables[m_TableName].Rows[0];

            CProperty v_Property = new CProperty();

            foreach (System.Data.DataColumn tempLoopVar_v_Column in m_ds.Tables[m_TableName].PrimaryKey)
            {
                v_Column = tempLoopVar_v_Column;
                v_Property.SetValues(v_Column.DataType, v_Column.ColumnName);
                v_Para = v_Property.CreateSQLValuePara();
                v_Para.Value = v_Row[v_Property.getName()];
                v_Cmd.Parameters.Add(v_Para);
            }

            //Gan cac thuoc tinh cua command
            v_Cmd.Connection = m_cnn;
            v_Cmd.CommandType = CommandType.StoredProcedure;
            v_Cmd.CommandText = c_PRPrefix + m_TableName + "_Delete";
            return v_Cmd;
        }
コード例 #2
0
 //' 12/09/2013 LinhDH thêm để insert được Log
 protected void set_value_4_paraInsertLog(SqlParameter i_obj_sqlpara, 
     CProperty i_obj_property,
     decimal i_dc_id_nguoi_dung)
 {
     i_obj_sqlpara.Value = i_dc_id_nguoi_dung;
 }
コード例 #3
0
        protected void setParaCollection4CmdInsertLog(System.Data.SqlClient.SqlCommand i_Cmd, 
            decimal i_dc_id_nguoi_dung,
            string i_str_ten_tham_so)
        {
            System.Data.DataColumn v_Column = default(System.Data.DataColumn);
            System.Data.DataRow v_Row = default(System.Data.DataRow);
            System.Data.SqlClient.SqlParameter v_Para = default(System.Data.SqlClient.SqlParameter);
            v_Row = m_ds.Tables[m_TableName].Rows[0];

            CProperty v_Property = new CProperty();
            foreach (System.Data.DataColumn tempLoopVar_v_Column in m_ds.Tables[m_TableName].Columns)
            {
                v_Column = tempLoopVar_v_Column;
                v_Property.SetValues(v_Column.DataType, v_Column.ColumnName);
                //tao cac tham so truyen vao cho Stored Procedure
                v_Para = v_Property.CreateSQLValuePara();
                //v_Para.Value = v_Row(v_Property.getName())
                set_value_4_para(v_Para, v_Property, v_Row);
                i_Cmd.Parameters.Add(v_Para);
            }

            //' LinhDH 09/12/2012: Add parameter có insert Log
            v_Property.SetValues(Type.GetType("Decimal"), i_str_ten_tham_so);
            //tao cac tham so truyen vao cho Stored Procedure
            v_Para = v_Property.CreateSQLValuePara();
            //v_Para.Value = v_Row(v_Property.getName())
            set_value_4_paraInsertLog(v_Para, v_Property, i_dc_id_nguoi_dung);
            i_Cmd.Parameters.Add(v_Para);
        }
コード例 #4
0
        //Lay ve tham so dung de chua loi do sql server tra ve
        //Protected Function getErrorParameter() As SqlClient.SqlParameter
        //    Dim v_sqlPara As New SqlClient.SqlParameter()
        //    v_sqlPara = New SqlClient.SqlParameter("@ErrorCode", System.Data.SqlDbType.Int)
        //    v_sqlPara.Direction = ParameterDirection.Output
        //    Return v_sqlPara
        //End Function
        //Dat cac gia tri cho cac thuoc tinh
        protected void set_value_4_para(SqlParameter i_obj_sqlpara, 
            CProperty i_obj_property,
            DataRow i_dr_value)
        {
            Type v_obj_type = i_dr_value.Table.Columns[i_obj_property.getName()].DataType;

            switch (v_obj_type.ToString())
            {
                case "System.String":
                    if (i_dr_value.IsNull(i_obj_property.getName()))
                    {
                        i_obj_sqlpara.Value = System.Convert.DBNull;
                    }
                    else
                    {
                        if (i_dr_value[i_obj_property.getName()].ToString().Trim().Length == 0)
                        {
                            i_obj_sqlpara.Value = System.Convert.DBNull;
                        }
                        else
                        {
                            i_obj_sqlpara.Value = i_dr_value[i_obj_property.getName()];
                        }
                    }
                    break;
                case "System.DateTime":
                    if (i_dr_value.IsNull(i_obj_property.getName()))
                    {
                        i_obj_sqlpara.Value = System.Convert.DBNull;
                    }
                    else
                    {
                        if (Convert.ToDateTime(i_dr_value[i_obj_property.getName()])
                            == Convert.ToDateTime("01/01/1900"))
                        {
                            i_obj_sqlpara.Value = System.Convert.DBNull;
                        }
                        else
                        {
                            i_obj_sqlpara.Value = i_dr_value[i_obj_property.getName()];
                        }
                    }
                    break;
                default:
                    i_obj_sqlpara.Value = i_dr_value[i_obj_property.getName()];
                    break;
            }
        }
コード例 #5
0
        protected void setParaCollection4Cmd(System.Data.SqlClient.SqlCommand i_Cmd)
        {
            System.Data.DataColumn v_Column = default(System.Data.DataColumn);
            System.Data.DataRow v_Row = default(System.Data.DataRow);
            System.Data.SqlClient.SqlParameter v_Para = default(System.Data.SqlClient.SqlParameter);
            v_Row = m_ds.Tables[m_TableName].Rows[0];

            CProperty v_Property = new CProperty();
            foreach (System.Data.DataColumn tempLoopVar_v_Column in m_ds.Tables[m_TableName].Columns)
            {
                v_Column = tempLoopVar_v_Column;
                v_Property.SetValues(v_Column.DataType, v_Column.ColumnName);
                //tao cac tham so truyen vao cho Stored Procedure
                v_Para = v_Property.CreateSQLValuePara();
                //v_Para.Value = v_Row(v_Property.getName())
                set_value_4_para(v_Para, v_Property, v_Row);
                i_Cmd.Parameters.Add(v_Para);
            }
            //i_Cmd.Parameters.Add(getErrorParameter())
        }