private void cmdAdd_Click(object sender, EventArgs e) { switch (selectedGrid) { case enumSelectedGrid.HeaderSelected: if (dataGridHeader.SelectedCells.Count > 0 || dataGridHeader.SelectedCells.Count == 0) { ArusStock.frmAntarGudangUpdate ifrmChild = new ArusStock.frmAntarGudangUpdate(this); ifrmChild.MdiParent = Program.MainForm; Program.MainForm.RegisterChild(ifrmChild); ifrmChild.Show(); } break; case enumSelectedGrid.DetailSelected: if (dataGridHeader.SelectedCells.Count > 0) { if (String.Compare(dataGridHeader.SelectedCells[0].OwningRow.Cells["DrGudang"].Value.ToString(), GlobalVar.Gudang) != 0) { MessageBox.Show("Hanya Untuk Gudang " + dataGridHeader.SelectedCells[0].OwningRow.Cells["DrGudang"].Value.ToString()); return; } if (String.Compare(dataGridHeader.SelectedCells[0].OwningRow.Cells["SyncFlag"].Value.ToString(), "True") == 0) { { MessageBox.Show("Data sudah diupload !, Tidak bisa tambah detail barang.."); return; } /*if (!SecurityManager.AskPasswordManager()) * { * return; * }*/ } try { GlobalVar.LastClosingDate = (DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglKirim"].Value; if ((DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglKirim"].Value <= GlobalVar.LastClosingDate) { throw new Exception(String.Format(Messages.Error.AlreadyClosingPJT, GlobalVar.LastClosingDate)); } ArusStock.frmAntarGudangDetailUpdate ifrmChild = new ArusStock.frmAntarGudangDetailUpdate(this, _RowID, _RecordID); ifrmChild.MdiParent = Program.MainForm; Program.MainForm.RegisterChild(ifrmChild); ifrmChild.Show(); } catch (System.Exception ex) { Error.LogError(ex); } } RefreshDetail(); dataGridDetail.Focus(); break; } }
public void Edit() { switch (selectedGrid) { case enumSelectedGrid.HeaderSelected: if (dataGridHeader.SelectedCells.Count > 0) { if (ChekGudang() != false) { try { DateTime dtAG = (DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglKirim"].Value; if ((DateTime)dtAG <= GlobalVar.LastClosingDate) { throw new Exception(String.Format(Messages.Error.AlreadyClosingPJT, GlobalVar.LastClosingDate)); } FillHeader(); ArusStock.frmAntarGudangUpdate ifrmChild = new ArusStock.frmAntarGudangUpdate(this, _RowID); ifrmChild.MdiParent = Program.MainForm; Program.MainForm.RegisterChild(ifrmChild); ifrmChild.Show(); } catch (System.Exception ex) { Error.LogError(ex); } } else { MessageBox.Show("Hanya Untuk Gudang " + _DrGudang + " Atau " + _KeGudang, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.DialogResult = DialogResult.OK; return; } } break; case enumSelectedGrid.DetailSelected: if (dataGridDetail.SelectedCells.Count > 0) { if (ChekGudang() != false) { try { DateTime?dtAG = new DateTime(); if (dataGridHeader.SelectedCells[0].OwningRow.Cells["DrGudang"].Value.ToString() == GlobalVar.Gudang) { dtAG = (DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglKirim"].Value; } else { dtAG = (dataGridHeader.SelectedCells[0].OwningRow.Cells["TglTerima"].Value.ToString() == "") ? DateTime.Now : (DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglTerima"].Value; } if (dataGridHeader.SelectedCells[0].OwningRow.Cells["KeGudang"].Value.ToString() == GlobalVar.Gudang) { dtAG = (DateTime)dataGridHeader.SelectedCells[0].OwningRow.Cells["TglKirim"].Value; } if (dataGridHeader.SelectedCells[0].OwningRow.Cells["SyncFlag"].Value.ToString() == "1") { if (!SecurityManager.AskPasswordManager()) { return; } } FillDetail(); ArusStock.frmAntarGudangDetailUpdate ifrmChild = new ArusStock.frmAntarGudangDetailUpdate(this, _RowIDD, _HeaderIDD); ifrmChild.MdiParent = Program.MainForm; Program.MainForm.RegisterChild(ifrmChild); ifrmChild.Show(); } catch (System.Exception ex) { Error.LogError(ex); } } else { MessageBox.Show("Hanya Untuk Gudang " + _DrGudang + " Atau " + _KeGudang, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.DialogResult = DialogResult.OK; return; } } break; } }