Пример #1
0
 public void Cancel()
 {
     if (this.csCancel.Enabled)
     {
         int id = int.Parse(this.grdSchedule.ActiveRow.Cells["ID"].Value.ToString());
         if (MessageBox.Show(this, "Are you sure you want to cancel appointment " + id.ToString() + "?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
         {
             FreightGateway.CancelClientInboundFreight(id, DateTime.Now, Environment.UserName);
             Refresh();
         }
     }
 }
Пример #2
0
        private void OnItemClick(object sender, System.EventArgs e)
        {
            dlgClientInboundFreight dlg = null;

            DispatchDataset.ClientInboundScheduleTableRow appointment = null;
            int id = 0;

            try {
                ToolStripItem item = (ToolStripItem)sender;
                switch (item.Name)
                {
                case "csNew":
                    appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                    switch (this.cboSchedule.SelectedItem.ToString())
                    {
                    case "Today": appointment.ScheduleDate = DateTime.Today; break;

                    case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break;
                    }
                    appointment.ConsigneeName = "ARGIX LOGISTICS NATIONAL";
                    appointment.CarrierName   = "ARGIX";
                    appointment.IsTemplate    = false;
                    dlg      = new dlgClientInboundFreight(appointment);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FreightGateway.AddClientInboundFreight(appointment);
                        Refresh();
                    }
                    break;

                case "csOpen":
                    id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value);
                    DispatchDataset.ClientInboundScheduleTableRow _freight = (DispatchDataset.ClientInboundScheduleTableRow) this.mSchedule.ClientInboundScheduleTable.Select("ID=" + id)[0];
                    appointment           = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                    appointment.ItemArray = _freight.ItemArray;
                    dlg      = new dlgClientInboundFreight(appointment);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FreightGateway.ChangeClientInboundFreight(appointment);
                        Refresh();
                    }
                    break;

                case "csClone":
                    id          = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value);
                    appointment = (DispatchDataset.ClientInboundScheduleTableRow) this.mSchedule.ClientInboundScheduleTable.Select("ID=" + id)[0];
                    DispatchDataset.ClientInboundScheduleTableRow clone = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                    switch (this.cboSchedule.SelectedItem.ToString())
                    {
                    case "Today": clone.ScheduleDate = DateTime.Today; break;

                    case "Advanced": clone.ScheduleDate = DateTime.Today.AddDays(1); break;
                    }
                    clone.VendorName       = appointment.VendorName;
                    clone.ConsigneeName    = appointment.ConsigneeName;
                    clone.ScheduledArrival = clone.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay;
                    if (!appointment.IsAmountNull())
                    {
                        clone.Amount = appointment.Amount;
                    }
                    if (!appointment.IsAmountTypeNull())
                    {
                        clone.AmountType = appointment.AmountType;
                    }
                    if (!appointment.IsFreightTypeNull())
                    {
                        clone.FreightType = appointment.FreightType;
                    }
                    if (!appointment.IsCommentsNull())
                    {
                        clone.Comments = appointment.Comments;
                    }
                    clone.IsTemplate = false;
                    dlg      = new dlgClientInboundFreight(clone);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FreightGateway.AddClientInboundFreight(clone);
                        Refresh();
                    }
                    break;

                case "csCancel":
                    Cancel();
                    break;

                case "csRefresh": Refresh(); break;

                case "csTempNew":
                    appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                    appointment.ConsigneeName = "ARGIX LOGISTICS NATIONAL";
                    appointment.IsTemplate    = true;
                    dlg      = new dlgClientInboundFreight(appointment, true);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FreightGateway.AddClientInboundFreight(appointment);
                        Refresh();
                    }
                    break;

                case "csTempOpen":
                    id = Convert.ToInt32(this.grdTemplates.ActiveRow.Cells["ID"].Value);
                    DispatchDataset.ClientInboundScheduleTableRow _template = (DispatchDataset.ClientInboundScheduleTableRow) this.mTemplates.ClientInboundScheduleTable.Select("ID=" + id)[0];
                    appointment           = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                    appointment.ItemArray = _template.ItemArray;
                    dlg      = new dlgClientInboundFreight(appointment, true);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FreightGateway.ChangeClientInboundFreight(appointment);
                        Refresh();
                    }
                    break;

                case "csTempCancel":
                    id = Convert.ToInt32(this.grdTemplates.ActiveRow.Cells["ID"].Value);
                    if (MessageBox.Show(this, "Are you sure you want to cancel appointment template " + id.ToString() + "?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        FreightGateway.CancelClientInboundFreight(id, DateTime.Now, Environment.UserName);
                        Refresh();
                    }
                    break;

                case "csTempLoad":
                    for (int i = 0; i < this.mTemplates.ClientInboundScheduleTable.Rows.Count; i++)
                    {
                        if (this.mTemplates.ClientInboundScheduleTable[i].Selected == true)
                        {
                            appointment              = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow();
                            appointment.ItemArray    = this.mTemplates.ClientInboundScheduleTable[i].ItemArray;
                            appointment.CreateUserID = Environment.UserName;
                            appointment.Created      = DateTime.Now;
                            switch (this.cboSchedule.SelectedItem.ToString())
                            {
                            case "Today": appointment.ScheduleDate = DateTime.Today; break;

                            case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break;
                            }
                            appointment.ScheduledArrival = appointment.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay;
                            appointment.IsTemplate       = false;
                            FreightGateway.AddClientInboundFreight(appointment);
                        }
                    }
                    Refresh();
                    break;

                case "csTempRefresh": Refresh(); break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }