Beispiel #1
0
    /// <summary>
    /// Load category from database
    /// </summary>
    /// <returns> </returns>
    public DataTable GetAllAbout()
    {
        DataTable  dtlTemp = new DataTable();
        SqlCommand command = new SqlCommand("SP_GetList_About", connectDatabase.Connection());

        command.CommandType = CommandType.StoredProcedure;
        return(dtlTemp = this.FillData(command));
    }
Beispiel #2
0
    /// <summary>
    /// Load records Customer from database
    /// </summary>
    /// <returns> </returns>
    public DataTable GetAllRecordCustomer()
    {
        ClearAllData();
        SqlConnection connectDB = connectDatabase.Connection();

        adapterCustomer = new SqlDataAdapter("SP_GetList_Customer", connectDB);
        adapterCustomer.Fill(dsetCustomer);
        dtblCustomer = dsetCustomer.Tables[0];
        connectDB.Close();
        return(dtblCustomer);
    }
Beispiel #3
0
    /// <summary>
    /// Function Create Command SQL With Array Parameters
    /// </summary>
    /// <param name="commandSql"></param>
    /// <param name="parameters"></param>
    ///  <returns> SqlCommand</returns>
    public static SqlCommand CreateCommand(String commandSql, params Object[] parameters)
    {
        SqlConnection connect = connectDB.Connection();
        SqlCommand    command = new SqlCommand(commandSql, connect);

        for (int i = 0; i < parameters.Length; i += 2)
        {
            command.Parameters.AddWithValue(parameters[i].ToString(), parameters[i + 1]);
        }
        return(command);
    }
Beispiel #4
0
    /// <summary>
    /// Function Insert Bill To database
    /// </summary>
    /// <param name="custID"></param>
    /// <param name="datePurchase"></param>
    /// <param name="totalNamePr"></param>
    /// <param name="totalQtt"></param>
    /// <param name="totalMoney"></param>
    /// <param name="typePayment"></param>
    /// <param name="statusPayment"></param>
    /// <returns></returns>
    public int InsertBill(int custID, DateTime datePurchase, string totalNamePr, int totalQtt, double totalMoney, int typePayment, bool statusPayment)
    {
        int           idBill  = -1;
        SqlConnection connect = connectDatabase.Connection();

        try
        {
            SqlCommand command = new SqlCommand("SP_Insert_Bill", connect);
            command.CommandType = CommandType.StoredProcedure;
            SqlParameter prCustID = command.Parameters.Add("@Customer_ID", SqlDbType.Int);
            prCustID.Value = custID;
            SqlParameter prPassword = command.Parameters.Add("@Date_Purcharse", SqlDbType.DateTime);
            prPassword.Value = datePurchase;
            SqlParameter prName = command.Parameters.Add("@TotalNameProduct", SqlDbType.NVarChar);
            prName.Value = totalNamePr;
            SqlParameter prTotalQtt = command.Parameters.Add("@TotalQuantity", SqlDbType.Int);
            prTotalQtt.Value = totalQtt;
            SqlParameter prTotalMoney = command.Parameters.Add("@TotalMoney", SqlDbType.Float);
            prTotalMoney.Value = totalMoney;
            SqlParameter prTypePayment = command.Parameters.Add("@Type_Payment_ID", SqlDbType.Int);
            prTypePayment.Value = typePayment;
            SqlParameter prPayment = command.Parameters.Add("@Status_Payment", SqlDbType.Bit);
            prPayment.Value = statusPayment;
            SqlParameter prID = command.Parameters.Add("@ID", SqlDbType.Int);
            prID.Direction = ParameterDirection.Output;
            int row = command.ExecuteNonQuery();
            if (row > 0)
            {
                idBill = Int32.Parse(prID.Value.ToString());
                connect.Close();
                return(idBill);
            }
            return(idBill);
        }
        catch (System.Exception ex)
        {
            Debug.Print(ex.Message);
            return(idBill);
        }
    }