示例#1
0
    public static dbo_RequisitionClass Select_Record(String Requisition_No, String Time_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        dbo_RequisitionClass clsdbo_Requisition = new dbo_RequisitionClass();
        SqlConnection        connection         = SAMDataClass.GetConnection();
        string     selectProcedure = "[RequisitionSelect_TimeNo]";
        SqlCommand selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        selectCommand.Parameters.AddWithValue("@Time_No", Time_No);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Requisition.Requisition_No     = reader["Requisition_No"] is DBNull ? null : reader["Requisition_No"].ToString();
                clsdbo_Requisition.Time_No            = reader["Time_No"] is DBNull ? null : reader["Time_No"].ToString();
                clsdbo_Requisition.User_ID            = reader["User_ID"] is DBNull ? null : reader["User_ID"].ToString();
                clsdbo_Requisition.Requisition_Date   = reader["Requisition_Date"] is DBNull ? null : (DateTime?)reader["Requisition_Date"];
                clsdbo_Requisition.Transaction_Date   = reader["Transaction_Date"] is DBNull ? null : (DateTime?)reader["Transaction_Date"];
                clsdbo_Requisition.Grand_Total_Qty    = reader["Grand_Total_Qty"] is DBNull ? null : (Int32?)reader["Grand_Total_Qty"];
                clsdbo_Requisition.Grand_Total_Amount = reader["Grand_Total_Amount"] is DBNull ? null : (Decimal?)reader["Grand_Total_Amount"];
                clsdbo_Requisition.Total_Commission   = reader["Total_Commission"] is DBNull ? null : (Decimal?)reader["Total_Commission"];
                clsdbo_Requisition.Tota_Point         = reader["Tota_Point"] is DBNull ? null : (Int16?)reader["Tota_Point"];
                clsdbo_Requisition.Status             = reader["Status"] is DBNull ? null : reader["Status"].ToString();
                clsdbo_Requisition.Replace_Sales      = reader["Replace_Sales"] is DBNull ? null : reader["Replace_Sales"].ToString();
            }
            else
            {
                clsdbo_Requisition = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Requisition);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Requisition);
    }
示例#2
0
    public static bool Update(dbo_RequisitionClass newdbo_RequisitionClass)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);


        SqlConnection connection      = SAMDataClass.GetConnection();
        string        updateProcedure = "[RequisitionUpdate]";
        SqlCommand    updateCommand   = new SqlCommand(updateProcedure, connection);

        updateCommand.CommandType = CommandType.StoredProcedure;
        if (newdbo_RequisitionClass.Requisition_No != null)
        {
            updateCommand.Parameters.AddWithValue("@NewRequisition_No", newdbo_RequisitionClass.Requisition_No);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewRequisition_No", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Time_No != null)
        {
            updateCommand.Parameters.AddWithValue("@NewTime_No", newdbo_RequisitionClass.Time_No);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTime_No", DBNull.Value);
        }
        if (newdbo_RequisitionClass.User_ID != null)
        {
            updateCommand.Parameters.AddWithValue("@NewUser_ID", newdbo_RequisitionClass.User_ID);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewUser_ID", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Requisition_Date.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewRequisition_Date", newdbo_RequisitionClass.Requisition_Date);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewRequisition_Date", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Transaction_Date.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewTransaction_Date", newdbo_RequisitionClass.Transaction_Date);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTransaction_Date", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Grand_Total_Qty.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewGrand_Total_Qty", newdbo_RequisitionClass.Grand_Total_Qty);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewGrand_Total_Qty", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Grand_Total_Amount.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewGrand_Total_Amount", newdbo_RequisitionClass.Grand_Total_Amount);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewGrand_Total_Amount", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Total_Commission.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewTotal_Commission", newdbo_RequisitionClass.Total_Commission);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTotal_Commission", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Tota_Point.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewTota_Point", newdbo_RequisitionClass.Tota_Point);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTota_Point", DBNull.Value);
        }
        if (newdbo_RequisitionClass.Status != null)
        {
            updateCommand.Parameters.AddWithValue("@NewStatus", newdbo_RequisitionClass.Status);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewStatus", DBNull.Value);
        }

        if (newdbo_RequisitionClass.Replace_Sales != null)
        {
            updateCommand.Parameters.AddWithValue("@NewReplace_Sales", newdbo_RequisitionClass.Replace_Sales);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewReplace_Sales", DBNull.Value);
        }



        updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            updateCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
示例#3
0
    public static bool Add(dbo_RequisitionClass clsdbo_Requisition, String Created_By)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "RequisitionInsert";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_Requisition.Requisition_No != null)
        {
            insertCommand.Parameters.AddWithValue("@Requisition_No", clsdbo_Requisition.Requisition_No);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }
        if (clsdbo_Requisition.Time_No != null)
        {
            insertCommand.Parameters.AddWithValue("@Time_No", clsdbo_Requisition.Time_No);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Time_No", DBNull.Value);
        }
        if (clsdbo_Requisition.User_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@User_ID", clsdbo_Requisition.User_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }
        if (clsdbo_Requisition.Requisition_Date.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Requisition_Date", clsdbo_Requisition.Requisition_Date);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Requisition_Date", DBNull.Value);
        }
        if (clsdbo_Requisition.Transaction_Date.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Transaction_Date", clsdbo_Requisition.Transaction_Date);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Transaction_Date", DBNull.Value);
        }
        if (clsdbo_Requisition.Grand_Total_Qty.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Grand_Total_Qty", clsdbo_Requisition.Grand_Total_Qty);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Grand_Total_Qty", DBNull.Value);
        }
        if (clsdbo_Requisition.Grand_Total_Amount.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Grand_Total_Amount", clsdbo_Requisition.Grand_Total_Amount);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Grand_Total_Amount", DBNull.Value);
        }
        if (clsdbo_Requisition.Total_Commission.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Total_Commission", clsdbo_Requisition.Total_Commission);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Total_Commission", DBNull.Value);
        }
        if (clsdbo_Requisition.Tota_Point.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Tota_Point", clsdbo_Requisition.Tota_Point);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Tota_Point", DBNull.Value);
        }
        if (clsdbo_Requisition.Status != null)
        {
            insertCommand.Parameters.AddWithValue("@Status", clsdbo_Requisition.Status);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Status", DBNull.Value);
        }
        if (clsdbo_Requisition.Replace_Sales != null)
        {
            insertCommand.Parameters.AddWithValue("@Replace_Sales", clsdbo_Requisition.Replace_Sales);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Replace_Sales", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Created_By))
        {
            insertCommand.Parameters.AddWithValue("@Created_By", Created_By);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Created_By", DBNull.Value);
        }

        insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            insertCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
示例#4
0
    public static bool Delete(dbo_RequisitionClass clsdbo_Requisition)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[RequisitionDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_Requisition.Requisition_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldRequisition_No", clsdbo_Requisition.Requisition_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldRequisition_No", DBNull.Value);
        }
        if (clsdbo_Requisition.Time_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldTime_No", clsdbo_Requisition.Time_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldTime_No", DBNull.Value);
        }

        /*if (clsdbo_Requisition.User_ID != null)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldUser_ID", clsdbo_Requisition.User_ID);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldUser_ID", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Requisition_Date.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldRequisition_Date", clsdbo_Requisition.Requisition_Date);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldRequisition_Date", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Transaction_Date.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTransaction_Date", clsdbo_Requisition.Transaction_Date);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTransaction_Date", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Grand_Total_Qty.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldGrand_Total_Qty", clsdbo_Requisition.Grand_Total_Qty);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldGrand_Total_Qty", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Grand_Total_Amount.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldGrand_Total_Amount", clsdbo_Requisition.Grand_Total_Amount);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldGrand_Total_Amount", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Total_Commission.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTotal_Commission", clsdbo_Requisition.Total_Commission);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTotal_Commission", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Tota_Point.HasValue == true)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTota_Point", clsdbo_Requisition.Tota_Point);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldTota_Point", DBNull.Value);
         * }
         * if (clsdbo_Requisition.Status != null)
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldStatus", clsdbo_Requisition.Status);
         * }
         * else
         * {
         *  deleteCommand.Parameters.AddWithValue("@OldStatus", DBNull.Value);
         * }*/
        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }