Exemple #1
0
        //Interface
        public dlgYardDetail(string terminal, bool parentIsActive, ref YardDS yard)
        {
            //Constructor
            try {
                //Set command button and menu identities (used for onclick handler)
                InitializeComponent();
                this.btnOk.Text     = CMD_OK;
                this.btnCancel.Text = CMD_CANCEL;

                //Set mediator service, data, and titlebar caption
                this.lblTerminal.Text = terminal;
                this.mParentIsActive  = parentIsActive;
                this.mYardDS          = yard;
                if (this.mYardDS.YardDetailTable.Count > 0)
                {
                    this.mYardID = this.mYardDS.YardDetailTable[0].YardID;
                    this.Text    = (this.mYardID > 0) ? "Yard (" + this.mYardID + ")" : "Yard (New)";
                }
                else
                {
                    this.Text = "Yard (Data Unavailable)";
                }
            }
            catch (Exception ex) { throw ex; }
        }
        public static YardDS GetYard(int terminalID, int yardID)
        {
            //Get a new or existing yard
            YardDS yard = new YardDS();

            try {
                if (yardID == 0)
                {
                    //New
                    YardDS.YardDetailTableRow row = yard.YardDetailTable.NewYardDetailTableRow();
                    row.YardID      = 0;
                    row.Description = "";
                    row.TerminalID  = terminalID;
                    row.IsActive    = true;
                    row.LastUpdated = DateTime.Now;
                    row.UserID      = System.Environment.UserName;
                    row.RowVersion  = "";
                    yard.YardDetailTable.AddYardDetailTableRow(row);
                }
                else
                {
                    //Existing
                    DataSet ds = Mediator.FillDataset("", "YardDetailTable", new object[] { terminalID, yardID });
                    if (ds != null)
                    {
                        yard.Merge(ds);
                    }
                }
            }
            catch (Exception ex) { throw ex; }
            return(yard);
        }
        public static bool UpdateYard(YardDS yard)
        {
            //Update an existing yard
            bool result = false;

            try {
                result = Mediator.ExecuteNonQuery("", new object[] { yard });
            }
            catch (Exception ex) { throw ex; }
            return(result);
        }
        public static int CreateYard(YardDS yard)
        {
            //Create a new yard
            int result = 0;

            try {
                result = (int)Mediator.ExecuteNonQueryWithReturn("", new object[] { yard });
            }
            catch (Exception ex) { throw ex; }
            return(result);
        }
        public static YardDS ViewYards(int terminalID)
        {
            //Get a list of yards
            YardDS yards = new YardDS();

            try {
                DataSet ds = Mediator.FillDataset("", "YardListTable", new object[] { terminalID });
                if (ds != null)
                {
                    yards.Merge(ds.Tables["YardListTable"].Select("", "Name", DataViewRowState.CurrentRows));
                }
            }
            catch (Exception ex) { throw ex; }
            return(yards);
        }