private void deleteBtn_Click(object sender, EventArgs e) { // Exit if no project list if (m_List == null) { return; } //Set the binfingList to current item BindingSource GroupHargaItem m_Item = (GroupHargaItem)bindingSource1.Current; CommandDeleteGroupHarga deleteGroup = new CommandDeleteGroupHarga(m_List, m_Item); m_AppController.ExecuteCommand(deleteGroup); }
private void button2_Click(object sender, EventArgs e) { /* This event will be called several times during form initialization. * We don't want to do anything with it until the runtime authors * list has been passed in. */ // Exit if no project list if (m_List == null) { return; } if (isNewRecord == true) { //Set the bindingList to current item bindingSource GroupHargaItem m_Item = (GroupHargaItem)bindingSource1.Current; // Create a new project CommandCreateGroupHarga createGroup = new CommandCreateGroupHarga(m_Item); GroupHargaItem newGroup = (GroupHargaItem)m_AppController.ExecuteCommand(createGroup); } else if (isNewRecord == false) { //Set the binfingList to current item BindingSource GroupHargaItem m_Item = (GroupHargaItem)bindingSource1.Current; //Update the record CommandUpdateGroupHarga updateGroup = new CommandUpdateGroupHarga(m_Item); GroupHargaItem groupToUpdate = (GroupHargaItem)m_AppController.ExecuteCommand(updateGroup); } isNewRecord = false; /* Since the BindingSource is managing the collection, we pass the new * author to the BindingSource, using the NewObject property of the * event args. The BindingSource will add the new author to the * AuthorList for us. */ //bindingSource1.Add(newGroup); }
internal void CreateDatabaseRecord(GroupHargaItem newGroup) { string sql = "INSERT INTO priceGroup " + "(groupCode,groupKet, groupStat) " + "OUTPUT INSERTED.groupCode " + "VALUES (@groupCode, @groupKet, @groupStat)"; try { //Create and open a connection SqlConnection connection = new SqlConnection(connectionString); connection.Open(); //create and configure a command SqlCommand command = new SqlCommand(sql, connection); //Adding value through parameter command.CommandType = System.Data.CommandType.Text; command.Parameters.Clear(); command.Parameters.AddWithValue("@groupCode", newGroup.GroupCode); command.Parameters.AddWithValue("@groupKet", newGroup.Keterangan); command.Parameters.AddWithValue("@groupStat", newGroup.Stat); //execute the command string numRowsAffected = Convert.ToString(command.ExecuteScalar()); //Close and dispose command.Dispose(); connection.Close(); connection.Dispose(); //set return value newGroup.GroupCode = numRowsAffected; } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { // Exit if no project list if (m_List == null) { return; } //Set the binfingList to current item BindingSource GroupHargaItem m_Item = (GroupHargaItem)bindingSource1.Current; // Confirm Delete string invoiceNumber = String.Format("{0}", m_Item.GroupCode); string message = String.Format("Delete Invoice '{0}' and all of its item?", invoiceNumber); DialogResult result = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); // Delete author if (result == DialogResult.Yes) { CommandDeleteGroupHarga deleteGroup = new CommandDeleteGroupHarga(m_List, m_Item); m_AppController.ExecuteCommand(deleteGroup); } }
public void ListGroupHarga(GrouphargaList list) { string sql = "SELECT [GROUPCODE],[groupKET],[GROUPSTAT] FROM [standArtInvoicingDB].[dbo].[priceGroup]"; DataSet dataSet = DataProvider.GetDataSet(sql); //Create variable for DataSet table DataTable groupPriceTabel = dataSet.Tables[0]; GroupHargaItem nextGroup = null; foreach (DataRow parentRow in groupPriceTabel.Rows) { nextGroup = new GroupHargaItem(); nextGroup.GroupCode = parentRow["GROUPCODE"].ToString(); nextGroup.Keterangan = parentRow["GROUPKET"].ToString(); nextGroup.Stat = Convert.ToBoolean(parentRow["GROUPSTAT"]); list.Add(nextGroup); } dataSet.Dispose(); }
internal void UpdateDatabaseRecord(GroupHargaItem changedGroup) { string sql = "UPDATE priceGroup SET " + "groupKet = @groupKet, " + "groupStat = @groupStat " + "WHERE groupCode = @groupCode"; try { //Create and open a connection SqlConnection connection = new SqlConnection(connectionString); connection.Open(); //create and configure a command SqlCommand command = new SqlCommand(sql, connection); //Adding value through parameter command.CommandType = System.Data.CommandType.Text; command.Parameters.Clear(); command.Parameters.AddWithValue("@groupCode", changedGroup.GroupCode); command.Parameters.AddWithValue("@groupKet", changedGroup.Keterangan); command.Parameters.AddWithValue("@groupStat", changedGroup.Stat); //execute the command string numRowsAffected = Convert.ToString(command.ExecuteScalar()); //Close and dispose command.Dispose(); connection.Close(); connection.Dispose(); } catch (SqlException ex) { MessageBox.Show(ex.Message.ToString()); } }
public CommandCreateGroupHarga(GroupHargaItem groupItem) { m_Item = groupItem; }
public CommandDeleteGroupHarga(GrouphargaList listItem, GroupHargaItem deleteItem) { m_groupList = listItem; m_Item = deleteItem; }