Exemplo n.º 1
0
        private void confirmUpdateProductBtn_Click(object sender, RoutedEventArgs e)
        {
            if (rbNewCategory.IsChecked == true)
            {
                int cateId = DatabaseAccess.SaveCategory(tbNewCategory.Text);
                Product.CakeCat = cateId;
            }
            else
            {
                Product.CakeCat = CategoryList[cbbCakeCat.SelectedIndex].CateId;
            }

            Product.CakeCode = txtCakeCode.Text;
            Product.CakeName = txtCakeName.Text;
            Product.CakeDesc = txtCakeDesc.Text;

            if (NewFilePath != "")
            {
                Product.CakeImage = NewFilePath.Split('\\').Last();
                File.Copy(FilePath, NewFilePath);
            }

            int producPrice = Product.CakePrice;

            int.TryParse(txtCakePrice.Text, out producPrice);
            Product.CakePrice = producPrice;
            int productQuantity = Product.CakeQuantity;

            int.TryParse(txtCakeQuantity.Text, out productQuantity);
            Product.CakeQuantity = productQuantity;

            DatabaseAccess.UpdateCake(Product);
            MessageBox.Show("Cập nhật thông tin bánh thành công!");
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            base.LoadVariables(context);

            StrNewSheetName    = NewSheetName.Get(context);
            StrNewFilePath     = NewFilePath.Get(context);
            StrNewFilePassword = NewFilePassword.Get(context);
            IsAutoCreate       = AutoFileCreation.Get(context);

            this.DoCopyToFile();
        }
Exemplo n.º 3
0
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                String workbookFullName = FilePath.Get(context);
                String newFileName      = NewFileName.Get(context);
                string newfilePath      = NewFilePath.Get(context);

                string   fileFormat               = ToDescriptionString(FileFormatType);
                String[] fileFormatTypeStr        = FileFormatType.ToString().TrimStart().Split('_');
                String   extension                = String.Concat(".", fileFormatTypeStr[0]);
                string   newFileNameWithExtension = String.Concat(newFileName, extension);

                string  workbookName     = string.Empty;
                dynamic xlWorkbook       = null;
                bool    excelFileVisible = false;

                if (true == NeedToOpen)
                {
                    excelFileVisible = true;
                }

                // Combine 2 path parts.
                string workbooknameas = Path.Combine(newfilePath, newFileName);
                string workbooknameasWithExtension = Path.Combine(newfilePath, newFileNameWithExtension);

                if (File.Exists(workbookFullName))
                {
                    ExcelHelper.Shared.Close_OpenedFile(workbookFullName);
                    workbookName = Path.GetFileName(workbookFullName);

                    ExcelHelper.Shared.GetApp(excelFileVisible).DisplayAlerts = false;
                    xlWorkbook = ExcelHelper.Shared.GetApp(excelFileVisible).Workbooks.Open(workbookFullName);

                    if (File.Exists(workbooknameasWithExtension))
                    {
                        if (true == IsOverride)
                        {
                            // xlWorkbook.SaveAs(workbooknameas, FileFormatType, Missing.Value, Missing.Value, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
                            XlFileFormat fm = (XlFileFormat)Enum.Parse(typeof(XlFileFormat), fileFormat);
                            xlWorkbook.SaveAs(workbooknameas, fm, Missing.Value, Missing.Value, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
                        }
                        else
                        {
                            Log.Logger.LogData("The file \"" + newFileName + "\" is already exists in activity Excel_Workbook_SaveAs", LogLevel.Error);
                            if (!ContinueOnError)
                            {
                                context.Abort();
                            }
                        }
                    }
                    else
                    {
                        // xlWorkbook.SaveAs(workbooknameas, XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
                        //xlWorkbook.SaveAs(workbooknameas, FileFormatType, Missing.Value,Missing.Value, false, false, XlSaveAsAccessMode.xlNoChange,XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
                        XlFileFormat fm = (XlFileFormat)Enum.Parse(typeof(XlFileFormat), fileFormat);
                        xlWorkbook.SaveAs(workbooknameas, fm, Missing.Value, Missing.Value, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
                    }
                    if (true == NeedToClose)
                    {
                        xlWorkbook.Close();
                    }
                    if (false == NeedToClose && false == NeedToOpen)
                    {
                        xlWorkbook.Close();
                    }
                    if (false == NeedToClose && true == NeedToOpen)
                    {
                        xlWorkbook.Close();
                        ExcelHelper.Shared.GetApp(excelFileVisible).Workbooks.Open(workbookFullName);
                    }
                    if (ExcelHelper.Shared.GetApp(excelFileVisible).Workbooks.Count == 0)
                    {
                        ExcelHelper.Shared.Dispose();
                    }
                }
                else
                {
                    Log.Logger.LogData("Excel file does not exist:\"" + workbookFullName + "\" in activity Excel_Workbook_SaveAs", LogLevel.Error);
                    if (!ContinueOnError)
                    {
                        context.Abort();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.LogData(ex.Message + " in activity Excel_Workbook_SaveAs", LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }