コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            WMSServiceClient serv = new WMSServiceClient();

            if (rdOpt.IsChecked == true)
            {
                // make the Count document
                if (Products == null || Products.Rows.Count == 0)
                {
                    Util.ShowError("Records not selected");
                    return;
                }

                NewTask();
            }
            else
            {
                //// make the schedule
                if (string.IsNullOrEmpty(Query))
                {
                    Util.ShowError("Records not selected");
                    return;
                }

                if (string.IsNullOrEmpty(txtTitle.Text))
                {
                    Util.ShowError("Name or Reference is required");
                    return;
                }

                if (string.IsNullOrEmpty(txtSchDateFrom.Text))
                {
                    Util.ShowError("Start Date is required");
                    return;
                }
                if (string.IsNullOrEmpty(txtSchDateTo.Text))
                {
                    Util.ShowError("End Date is required");
                    return;
                }
                if (string.IsNullOrEmpty(txtFrecuency.Text))
                {
                    Util.ShowError("Frecuency field is required");
                    return;
                }
                if (txtSchDateFrom.SelectedDate >= txtSchDateTo.SelectedDate)
                {
                    Util.ShowError("End Date must be older than Start Date");
                    return;
                }

                // CAA [2010/05/05] Valida que se incluyan las columnas necesarias en el reporte
                if (cboToDo.SelectedIndex == 0) //Only BIN
                {
                    if (!Query.Contains("as BinCode"))
                    {
                        Util.ShowError("BinCode column missing.");
                        return;
                    }
                }
                else
                    if (cboToDo.SelectedIndex == 1) // BIN & PRODUCT
                    {
                        if (!Query.Contains("as BinCode") || (!Query.Contains("as Product FROM") && !Query.Contains("as Product,")))
                        {
                            Util.ShowError("BinCode and/or Product columns are missing.");
                            return;
                        }
                    }



                CountSchedule sch = new CountSchedule
                {
                    Start = txtSchDateFrom.SelectedDate.Value, // DateTime.Parse(txtSchDateFrom.Text);
                    Finish = txtSchDateTo.SelectedDate.Value, // DateTime.Parse(txtSchDateTo.Text);
                    NextDateRun = txtSchDateFrom.SelectedDate.Value, //.AddDays(double.Parse(txtFrecuency.Text));
                    IsDone = false,
                    Query = Query,
                    Parameters = queryParam.GetXml(),
                    RepeatEach = short.Parse(txtFrecuency.Text),
                    CreatedBy = App.curUser.UserName,
                    CreationDate = DateTime.Now,
                    Location = App.curLocation,
                    CountOption = cboToDo.SelectedIndex,
                    Title = txtTitle.Text
                };
                

                sch = serv.SaveCountSchedule(sch);

                Util.ShowMessage("Cycle Count Scheduled.");
            }

            ClosePopup();
        }