示例#1
0
 //bind all  Creditors in to a list
 public List <CreditorModel> FillCreditorGrid()
 {
     using (MySqlConnection sqlConn = new MySqlConnection(conString))
     {
         sqlConn.Open();
         String               query           = @"SELECT CreditorId , AgentName, CreditorDue, Date,
             CompanyName, 
             PhoneNumber  FROM  creditor JOIN agent On creditor.AgentId = agent.AgentId ; ";
         MySqlCommand         cmd             = new MySqlCommand(query, sqlConn);
         MySqlDataReader      mySqlDataReader = cmd.ExecuteReader();
         List <CreditorModel> creditorModels  = new List <CreditorModel>();
         while (mySqlDataReader.Read())
         {
             CreditorModel creditorModel = new CreditorModel();
             creditorModel.CreditorId  = (int)mySqlDataReader["CreditorId"];
             creditorModel.AgentName   = mySqlDataReader["AgentName"].ToString();
             creditorModel.CreditorDue = Convert.ToDecimal(mySqlDataReader["CreditorDue"]);
             creditorModel.Date        = Convert.ToDateTime(mySqlDataReader["Date"].ToString());
             creditorModel.CompanyName = mySqlDataReader["CompanyName"].ToString();
             creditorModel.PhoneNumber = mySqlDataReader["PhoneNumber"].ToString();
             creditorModels.Add(creditorModel);
         }
         mySqlDataReader.Close();
         sqlConn.Close();
         return(creditorModels);
     }
 }
示例#2
0
 //creditor grid view cell click
 private void creditorGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (creditorGridView.CurrentRow != null)
     {
         selectedCreditorModel = (CreditorModel)creditorGridView.CurrentRow.DataBoundItem;
         creditorId.Text       = selectedCreditorModel.CreditorId.ToString();
         creditorDue.Text      = selectedCreditorModel.CreditorDue.ToString();
     }
 }
示例#3
0
        //Delete creditor
        public int DeleteCreditor(CreditorModel creditorModel)
        {
            String query = "DELETE FROM creditor  WHERE CreditorId = @creditorId; ";

            using (MySqlConnection sqlConn = new MySqlConnection(conString))
            {
                using (MySqlCommand cmd = new MySqlCommand(query, sqlConn))
                {
                    sqlConn.Open();

                    cmd.Parameters.AddWithValue("@creditorId", creditorModel.CreditorId);
                    int isUpdate = cmd.ExecuteNonQuery();
                    sqlConn.Close();
                    return(isUpdate);
                }
            }
        }
示例#4
0
        //creditor insert
        public int CreditorInsert(CreditorModel creditorModel)
        {
            string query = @"INSERT INTO creditor (CreditorDue,Date,AgentId) VALUES (@CreditorDue , @Date , @AgentId);";

            using (MySqlConnection sqlConn = new MySqlConnection(conString))
            {
                using (MySqlCommand cmd = new MySqlCommand(query, sqlConn))
                {
                    sqlConn.Open();
                    cmd.Parameters.AddWithValue("@CreditorDue", creditorModel.CreditorDue);
                    cmd.Parameters.AddWithValue("@Date", creditorModel.Date);
                    cmd.Parameters.AddWithValue("@AgentId", creditorModel.AgentId);

                    int IsInserted = cmd.ExecuteNonQuery();
                    sqlConn.Close();
                    return(IsInserted);
                }
            }
        }
示例#5
0
 public int InsertCreditor(CreditorModel creditorModel)
 {
     return(creditorGateway.CreditorInsert(creditorModel));
 }
示例#6
0
 public int DeleteCreditor(CreditorModel creditorModel)
 {
     return(creditorGateway.DeleteCreditor(creditorModel));
 }
示例#7
0
 public int UpdateCreditor(CreditorModel creditorModel)
 {
     return(creditorGateway.UpdateCreditor(creditorModel));
 }