Ejemplo n.º 1
0
        private bool ValidateExcelObject()
        {
            var validation = new ValidationObject();

            validation.StartValidation(ref excelList, excelTemplate);

            if (validation.isError)
            {
                var messageLabel = WarningMessageBox.FindControl("WarningLabel") as System.Web.UI.WebControls.Label;
                messageLabel.Text = validation.GetMassegaForError();
                WarningMessageBox.Show();
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void SaveExcelObjects(string xml)
        {
            bool isAllRight = true;

            using (var c = new SqlConnection(Teleform.ProjectMonitoring.HttpApplication.Global.ConnectionString))
                using (var command = new SqlCommand(xml, c))
                {
                    c.Open();
                    SqlTransaction transaction = c.BeginTransaction();

                    try
                    {
                        command.Transaction = transaction;
                        command.ExecuteScalar();

                        transaction.Commit();
                    }
                    catch (SqlException ex)
                    {
                        transaction.Rollback();
                        isAllRight = false;

                        string duplecateObjects = ErrorHandling(ex.Errors);

                        var messageLabel = WarningMessageBox.FindControl("WarningLabel") as System.Web.UI.WebControls.Label;
                        messageLabel.Text = duplecateObjects;
                        WarningMessageBox.Show();
                    }
                }
            if (isAllRight)
            {
                var messageLabel = WarningMessageBox.FindControl("WarningLabel") as System.Web.UI.WebControls.Label;
                messageLabel.Text = "Данные успешно сохранены в тип объекта : " + excelTemplate.Entity.Name;
                WarningMessageBox.Show();
            }
        }