Exemple #1
0
        protected void popupDocUpload_OnWindowCallback(object source, PopupWindowCallbackArgs e)
        {
            if (e.Parameter == "upload")
            {
                string filePath = Session["pl_uploaded_file"] as string;

                PackingListUploader uploader = new PackingListUploader();

                //set username for column createdby and modifiedby
                uploader.Username = PermissionHelper.GetAuthenticatedUserName();

                //parameter
                //DateTime value = (DateTime) dtPM.Value;
                int packingMonth = Session["PM"].ToInt32(0);
                int modelId      = Session["ModelId"].ToInt32(0);
                int ricType      = cmbRicType.Value.ToInt32(0);

                //parse the file
                string message  = "";
                int    rowCount = uploader.Parse(filePath, packingMonth, modelId, ricType);
                if (rowCount > 0)
                {
                    lblSuccess.Text = "Successfully upload and process data " + Path.GetFileName(filePath) + ", " + rowCount + " rows inserted, " + message;

                    //this.masterGrid.DataBindSafe();

                    int stepId = Session["StepId"].ToInt32(0);
                    ChecklistHelper.ReleaseStep(stepId);

                    string       gridName = Session["StepGrid"].ToString();
                    ASPxGridView grid     = this.Page.FindNestedControl2(gridName) as ASPxGridView;
                    if (grid != null)
                    {
                        grid.DataBindSafe();
                    }
                }
                else
                {
                    if (uploader.ErrorMessage.Length > 0)
                    {
                        lblSuccess.Text = uploader.ErrorMessage;
                    }
                    else
                    {
                        lblSuccess.Text = "Upload file " + Path.GetFileName(filePath) + " failed!";
                    }
                    //delete the file
                    File.Delete(filePath);

                    //e.CallbackData = lblSuccess.Text;

                    //e.IsValid = false;
                    //e.ErrorText = lblSuccess.Text;
                }
            }
            else
            {
                string[] arr = e.Parameter.Split(GridViewHelper.SEPARATOR_VALUES);
                if (arr.Length < 1)
                {
                    return;
                }

                int    instanceStepId = arr[0].ToInt32(0);
                string gridName       = arr[1];

                ChecklistInstanceStep step = ChecklistHelper.GetChecklistStep(instanceStepId);
                if (step == null || step.ChecklistInstance == null)
                {
                    return;
                }

                // get parameter
                DateTime dt           = DateTime.Parse(ChecklistHelper.GetChecklistParameterValue(step.ChecklistInstanceId, "PackingMonth"));
                int      packingMonth = dt.ToString("yyyyMM").ToInt32(0);
                int      modelId      = ChecklistHelper.GetChecklistParameterValue(step.ChecklistInstanceId, "CatalogModelId").ToInt32(0);

                Session["PM"]       = packingMonth;
                Session["ModelId"]  = modelId;
                Session["StepId"]   = instanceStepId;
                Session["StepGrid"] = gridName;

                lblSuccess.Text = "";
                //txtPM.Value = packingMonth.ToString();
                //txtModelId.Value = modelId;
                ////cmbRicType.Value = 0;
            }
        }