private void bindingNavigatorSaveItem_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } if (channelIdTextBox.Enabled == true) { cust = new MChannel(); } else { cust = (MChannel)DataMaster.GetObjectById(typeof(MChannel), channelIdTextBox.Text); } cust.ChannelAddress = channelAddressTextBox.Text; //cust.ChannelDisc = decimal.Zero; cust.ChannelFax = channelFaxTextBox.Text; cust.ChannelId = channelIdTextBox.Text; //cust.ChannelLimit = decimal.Zero; cust.ChannelName = channelNameTextBox.Text; cust.ChannelPhone = channelPhoneTextBox.Text; cust.ChannelStatus = ListOfCustStatus.Active.ToString(); //cust.SubAccountId = string.Empty; cust.ModifiedBy = lbl_UserName.Text; cust.ModifiedDate = DateTime.Now; if (channelIdTextBox.Enabled == true) { try { DataMaster.SavePersistence(cust); } catch (NHibernate.NonUniqueObjectException) { RecreateBalloon(); balloonHelp.Caption = "Validasi data kurang"; balloonHelp.Content = "Channel dengan kode " + channelIdTextBox.Text + " sudah pernah diinput, silahkan input dengan kode yang lain"; balloonHelp.ShowBalloon(channelIdTextBox); channelIdTextBox.Focus(); return; } ModuleControlSettings.SaveLog(ListOfAction.Insert, channelIdTextBox.Text, ListOfTable.MChannel, lbl_UserName.Text); } else { DataMaster.UpdatePersistence(cust); ModuleControlSettings.SaveLog(ListOfAction.Update, channelIdTextBox.Text, ListOfTable.MChannel, lbl_UserName.Text); } BindData(); }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(channelIdTextBox.Text.Trim())) { if (MessageBox.Show("Anda yakin menghapus data?", "Konfirmasi Hapus Data", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { cust = (MChannel)DataMaster.GetObjectById(typeof(MChannel), channelIdTextBox.Text); DataMaster.Delete(cust); ModuleControlSettings.SaveLog(ListOfAction.Delete, channelIdTextBox.Text, ListOfTable.MChannel, lbl_UserName.Text); BindData(); } } }
internal static void FillChannelComboBox(ComboBox channelIdComboBox) { DataMasterMgtServices DataMaster = new DataMasterMgtServices(); channelIdComboBox.DropDownStyle = ComboBoxStyle.DropDownList; NHibernate.Expression.Order[] orderArrays = new NHibernate.Expression.Order[1]; orderArrays[0] = NHibernate.Expression.Order.Asc(MChannel.ColumnNames.ChannelName); IList list = DataMaster.GetList(typeof(MChannel), null, orderArrays); MChannel chn = new MChannel(); chn.ChannelName = "- Channel -"; list.Insert(0, chn); //DataTable dt = new DataTable(); //dt.Columns.Add(MChannel.ColumnNames.ChannelId); //dt.Columns.Add(MChannel.ColumnNames.ChannelName); //DataRow dr; //IList listChannelType = DataMaster.GetAll(typeof(MChannel)); //MChannel channel = new MChannel(); //channel.ChannelName = "- Channel -"; //dr = dt.NewRow(); //dr[0] = channel.ChannelId; //dr[1] = channel.ChannelName; //dt.Rows.Add(dr); //for (int i = 0; i < listChannelType.Count; i++) //{ // channel = (MChannel)listChannelType[i]; // dr = dt.NewRow(); // dr[0] = channel.ChannelId; // dr[1] = channel.ChannelName; // dt.Rows.Add(dr); //} channelIdComboBox.DataSource = list; channelIdComboBox.DisplayMember = MChannel.ColumnNames.ChannelName; channelIdComboBox.ValueMember = MChannel.ColumnNames.ChannelId; channelIdComboBox.Show(); }