private void deleteRecordToolStripMenuItem_Click(object sender, EventArgs e) { string _str = "Are You Sure You Want To Delete This Entry"; if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } ic.batch_no_SettingC _obj = fGrid.SelectedRows[0].Tag as ic.batch_no_SettingC; if (_obj != null) { using (var xd = new xing()) { if (xd.SingleUpdateCommand(string.Format("delete from off_batch_no_settings_tb where un_id={0} and entrant_count=0", _obj.un_id))) { xd.CommitTransaction(); fGrid.Rows.RemoveAt(fGrid.Rows[_obj.un_id.ToString()].Index); } else { MessageBox.Show("This Batch No Is Already Attached To Some Receipts,Cancel Them In Order To Proceed", "Delete Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } }
private void buttoncreate_Click(object sender, EventArgs e) { if (fGrid.CurCell != null) { fGrid.CommitEditCurCell(); } if (!IsValid()) { return; } string _str = "Are You Sure You Want To Save This Record ??"; if (!dbm.WarningMessage(_str, "Save Warning")) { return; } // ic.batch_no_SettingC _obj = new ic.batch_no_SettingC(); _obj.batch_count = fGrid.Rows["batch_count"].Cells[1].Value.ToInt32(); _obj.batch_no = fGrid.Rows["batch_no"].Cells[1].Text.ToUpper(); _obj.batch_total = fGrid.Rows["batch_total"].Cells[1].Value.ToInt32(); _obj.entrant_id = (fGrid.Rows["data_entrant"].Cells[1].AuxValue as fnn.iGComboItemEX).ID; _obj.sab_fs_id = m_sabbath.fs_id; using (var xd = new xing()) { var _ret_val = xd.SingleInsertCommandIgnore("off_batch_no_settings_tb", new string[] { "batch_no", "batch_count", "fs_time_stamp", "batch_total", "entrant_id", "lch_id", "sab_fs_id" }, new object[] { _obj.batch_no, _obj.batch_count, 0, _obj.batch_total, _obj.entrant_id, datam.LCH_ID, _obj.sab_fs_id }); if (_ret_val == 0) { MessageBox.Show("You Have Already Entered This BATCH NUMBER", "DUPLICATE BATCH NO", MessageBoxButtons.OK, MessageBoxIcon.Error); fGrid.Focus(); fGrid.SetCurCell("batch_no", 1); fGrid.Rows["batch_no"].Cells[1].Value = null; return; } xd.CommitTransaction(); } (this.Owner as BatchNoManager).CheckForUpdates(); ClearGrid(); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { if (fGrid.SelectedRows.Count == 0) { e.Cancel = true; return; } if (fGrid.SelectedRows[0].Level == 0) { e.Cancel = true; return; } ic.batch_no_SettingC _obj = fGrid.SelectedRows[0].Tag as ic.batch_no_SettingC; if (_obj.entrant_count != 0 & _obj.entrant_total != 0) { e.Cancel = true; } }
public static bool fill_batch_no_sabbath(xing xd, int sab_fs_id) { if (DATA_BATCH_NO_SETTINGS == null) { DATA_BATCH_NO_SETTINGS = new SortedList <int, SortedList <int, ic.batch_no_SettingC> >(); } if (sab_fs_id == 0) { return(false); } if (DATA_BATCH_NO_SETTINGS.IndexOfKey(sab_fs_id) == -1) { DATA_BATCH_NO_SETTINGS.Add(sab_fs_id, new SortedList <int, ic.batch_no_SettingC>()); } string _table_name = "off_batch_no_settings_tb"; if (wdata.TABLE_STAMP == null) { wdata.TABLE_STAMP = new SortedList <string, long>(); } if (wdata.TABLE_STAMP.IndexOfKey(_table_name) == -1) { wdata.TABLE_STAMP.Add(_table_name, 0); } bool is_new = false; bool load_all = false; string _str = string.Empty; long _stamp = xd.GetTimeStamp(_table_name); if (DATA_BATCH_NO_SETTINGS[sab_fs_id].Keys.Count == 0) { _str = string.Format("select * from {0} where sab_fs_id={1}", _table_name, sab_fs_id); load_all = true; } else { if (wdata.TABLE_STAMP[_table_name] == _stamp) { return(false); } _str = string.Format("select * from {0} where sab_fs_id={1} and fs_time_stamp > {2}", _table_name, sab_fs_id, wdata.TABLE_STAMP[_table_name]); load_all = false; } wdata.TABLE_STAMP[_table_name] = _stamp; ic.batch_no_SettingC _obj = null; #region database fill using (var _dr = xd.SelectCommand(_str)) { while (_dr.Read()) { _obj = null; if (load_all) { _obj = new ic.batch_no_SettingC(); is_new = true; } else { try { _obj = datam.DATA_BATCH_NO_SETTINGS[sab_fs_id][_dr["un_id"].ToInt32()]; is_new = false; } catch (Exception ex) { if (_obj == null) { _obj = new ic.batch_no_SettingC(); is_new = true; } } } if (is_new) { _obj.un_id = _dr["un_id"].ToInt32(); _obj.entrant_id = _dr["entrant_id"].ToInt32(); _obj.sab_fs_id = _dr["sab_fs_id"].ToInt32(); _obj.batch_count = _dr["batch_count"].ToInt32(); _obj.batch_no = _dr["batch_no"].ToStringNullable(); _obj.batch_total = _dr["batch_total"].ToInt32(); datam.DATA_BATCH_NO_SETTINGS[sab_fs_id].Add(_obj.un_id, _obj); } // _obj.entrant_count = _dr["entrant_count"].ToInt32(); _obj.entrant_total = _dr["entrant_total"].ToInt32(); } _dr.Close(); _dr.Dispose(); } return(true); #endregion }