Пример #1
0
 private void ExtraCostGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (ExtraCostGridView.CurrentRow != null)
     {
         selectedExtraCostModel = (ExtraCostModel)ExtraCostGridView.CurrentRow.DataBoundItem;
         costId.Text            = selectedExtraCostModel.ExtraCostId.ToString();
         costDescTextbox.Text   = selectedExtraCostModel.CostType;
         amountTextbox.Text     = selectedExtraCostModel.Amount.ToString();
     }
 }
Пример #2
0
        //Extracost Delete
        public int DeleteExtraCost(ExtraCostModel extraCostModel)
        {
            String query = "DELETE FROM extracost    WHERE `CostId` = " + extraCostModel.ExtraCostId + ";";


            using (MySqlConnection sqlCon = new MySqlConnection(conString))
            {
                using (MySqlCommand cmd = new MySqlCommand(query, sqlCon))
                {
                    sqlCon.Open();
                    int k = cmd.ExecuteNonQuery();
                    sqlCon.Close();
                    return(k);
                }
            }
        }
Пример #3
0
        // extracost  update
        public int UpdateExtraCost(ExtraCostModel extraCostModel)
        {
            String query = @"UPDATE extracost SET CostType=  @CostType , Amount= @Amount Where CostId=" + extraCostModel.ExtraCostId + ";";


            using (MySqlConnection sqlConn = new MySqlConnection(conString))
            {
                using (MySqlCommand cmd = new MySqlCommand(query, sqlConn))
                {
                    sqlConn.Open();
                    cmd.Parameters.AddWithValue("@CostType", extraCostModel.CostType);
                    cmd.Parameters.AddWithValue("@Amount", extraCostModel.Amount);
                    // cmd.Parameters.AddWithValue("@Date", extraCostModel.CostDate);

                    int isUpdate = cmd.ExecuteNonQuery();
                    sqlConn.Close();
                    return(isUpdate);
                }
            }
        }
Пример #4
0
        //Extra Cost insert
        public int ExtraCostInsert(ExtraCostModel extraCostModel)
        {
            string query = @"INSERT INTO extracost  (CostType, Amount, Date) VALUES(@CostType, @Amount, @Date);";

            using (MySqlConnection sqlConn = new MySqlConnection(conString))
            {
                using (MySqlCommand cmd = new MySqlCommand(query, sqlConn))
                {
                    sqlConn.Open();
                    cmd.Parameters.AddWithValue("@CostType", extraCostModel.CostType);
                    cmd.Parameters.AddWithValue("@Amount", extraCostModel.Amount);
                    cmd.Parameters.AddWithValue("@Date", extraCostModel.CostDate);


                    int IsInserted = cmd.ExecuteNonQuery();
                    sqlConn.Close();
                    return(IsInserted);
                }
            }
        }
Пример #5
0
 //bind all Extracost  in to a list
 public List <ExtraCostModel> FillExtraCostGrid()
 {
     using (MySqlConnection sqlConn = new MySqlConnection(conString))
     {
         sqlConn.Open();
         String                query           = "SELECT * FROM extracost; ";
         MySqlCommand          cmd             = new MySqlCommand(query, sqlConn);
         MySqlDataReader       mySqlDataReader = cmd.ExecuteReader();
         List <ExtraCostModel> extraCostModels = new List <ExtraCostModel>();
         while (mySqlDataReader.Read())
         {
             ExtraCostModel extraCostModel = new ExtraCostModel();
             extraCostModel.ExtraCostId = (int)mySqlDataReader["CostId"];
             extraCostModel.CostType    = mySqlDataReader["CostType"].ToString();
             extraCostModel.Amount      = Convert.ToDecimal(mySqlDataReader["Amount"].ToString());
             extraCostModel.CostDate    = Convert.ToDateTime(mySqlDataReader["Date"].ToString());
             extraCostModels.Add(extraCostModel);
         }
         mySqlDataReader.Close();
         sqlConn.Close();
         return(extraCostModels);
     }
 }
Пример #6
0
 //Extracost delete call
 public int DeleteExtraCost(ExtraCostModel extraCostModel)
 {
     return(costGateway.DeleteExtraCost(extraCostModel));
 }
Пример #7
0
        //Extracost update call

        public int ExtraCostUpdate(ExtraCostModel extraCostModel)
        {
            int IsUpdate = costGateway.UpdateExtraCost(extraCostModel);

            return(IsUpdate);
        }
Пример #8
0
        //Extracost Insert call
        public int ExtraCostInsert(ExtraCostModel extraCostModel)
        {
            int Isinsert = costGateway.ExtraCostInsert(extraCostModel);

            return(Isinsert);
        }