コード例 #1
0
        /// <summary>
        /// ตรวจสอบ Require Field
        /// </summary>
        /// <returns></returns>
        private bool ValidateData()
        {
            Boolean bPass = true;

            errorProvider.Clear();


            if (Util.IsNullOrEmpty(txtUsername.Text))
            {
                errorProvider.SetError(txtUsername, Util.GetMessageText(eMsgId.COM0024, "Username"));
                bPass = false;
            }

            if (Util.IsNullOrEmpty(txtPassword.Text))
            {
                errorProvider.SetError(txtPassword, Util.GetMessageText(eMsgId.COM0024, "Password"));
                bPass = false;
            }


            if (!bPass)
            {
                AppEnvironment.CloseWaitForm();
            }

            return(bPass);
        }
        private void btnPrintPreview_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateRequire())
                {
                    return;
                }

                DataTable dtbResult = m_bizReport.GetMOHSummaryReport(Util.ConvertObjectToInteger(cboMonth.SelectedValue), txtYear.IntValue);

                if (!Util.IsNullOrEmptyOrZero(dtbResult.Rows.Count))
                {
                    AppEnvironment.ShowWaitForm("Please Wait", "Initializing Report.");
                    ReportDocument rpt = ReportUtil.LoadReport("RPT010_MOHSummaryReport.rpt");
                    rpt.SetDataSource(dtbResult);
                    string monthYear = cboMonth.Text + " " + txtYear.Text;
                    rpt.SetParameterValue("MonthYear", monthYear);
                    FrmPreviewReport frmPrint = new FrmPreviewReport();

                    AppEnvironment.CloseWaitForm();

                    ReportUtil.PrintPreviewReport(frmPrint, rpt);
                }
                else
                {
                    MessageBox.Show("Data not Found.", "RPT010", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                AppEnvironment.CloseWaitForm();
                ExceptionManager.ManageException(this, ex);
            }
        }
コード例 #3
0
        private void btnPrintPreview_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateRequire())
                {
                    return;
                }

                if (radioBtnType1.Checked)
                {
                    strItemType = radioBtnType1.Text;
                }
                else
                {
                    strItemType = radioBtnType2.Text;
                }

                DataTable dtbResult = m_bizReport.GetCostReports(txtYear.IntValue, Util.ConvertObjectToInteger(cboMonth.SelectedValue)
                                                                 , strProdDateFrom, strProdDateTo, strProdOrderNoFrom, strProdOrderNoTo, strItemType);

                if (!Util.IsNullOrEmptyOrZero(dtbResult.Rows.Count))
                {
                    AppEnvironment.ShowWaitForm("Please Wait", "Initializing Report.");
                    ReportDocument rpt = ReportUtil.LoadReport("RPT020_CostReport.rpt");
                    rpt.SetDataSource(dtbResult);
                    string monthYear = cboMonth.Text + " " + txtYear.Text;

                    DateTime minDate = dtbResult.AsEnumerable()
                                       .Select(cols => cols.Field <DateTime>("DocDate"))
                                       .FirstOrDefault();

                    DateTime maxDate = dtbResult.AsEnumerable()
                                       .Select(cols => cols.Field <DateTime>("DocDate"))
                                       .OrderByDescending(p => p.Ticks)
                                       .FirstOrDefault();

                    //string dateMinMax = minDate.ToString("dd/MM/yyyy") + " - " + maxDate.ToString("dd/MM/yyyy");
                    string dateMinMax = ProdDateFrom.Text + " - " + ProdDateTo.Text;
                    rpt.SetParameterValue("dateMinMax", dateMinMax);
                    rpt.SetParameterValue("MonthYear", monthYear);
                    FrmPreviewReport frmPrint = new FrmPreviewReport();

                    AppEnvironment.CloseWaitForm();

                    ReportUtil.PrintPreviewReport(frmPrint, rpt);
                }
                else
                {
                    MessageBox.Show("Data not Found.", "RPT020", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                AppEnvironment.CloseWaitForm();
                ExceptionManager.ManageException(this, ex);
            }
        }
コード例 #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateData())
                {
                    return;
                }

                AppEnvironment.ShowWaitForm();

                //==========================
                // ตรวจสอบ User + Pass บนฐานข้อมูล
                //==========================
                //bool bCheckUserPasswordValid = m_bizLogin.CheckUserPassword(txtUsername.Text.Trim(), txtPassword.Text.Trim());
                string encryptPassword         = DataUtil.Encrypt(txtPassword.Text.Trim());
                bool   bCheckUserPasswordValid = (CurrentUser != null && CurrentUser.Password == encryptPassword);

                if (!bCheckUserPasswordValid)
                {
                    tmCurrentDateTime.Enabled = false;
                    MessageDialog.ShowBusinessErrorMsg(this, Util.GetMessageText(eMsgId.COM0021));
                    AppEnvironment.UserLogin = null;

                    txtUsername.Focus();
                    txtUsername.SelectAll();
                    tmCurrentDateTime.Enabled = true;

                    return;
                }


                //====================================
                //string dbUsername = m_bizLogin.GetUsername(txtUsername.Text.Trim());
                AppEnvironment.UserLogin = CurrentUser.Username;

                AppEnvironment.DatabaseName = AppConfig.DatabaseName;
                tmCurrentDateTime.Enabled   = false;
                tmCurrentDateTime.Stop();
                tmCurrentDateTime.Dispose();

                AppEnvironment.CloseWaitForm();

                //==========================
                AppEnvironment.Log.Info("Login Success");

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                tmCurrentDateTime.Enabled = false;
                ExceptionManager.ManageException(this, ex);
                tmCurrentDateTime.Enabled = true;
            }
        }
コード例 #5
0
 public void CalculateData()
 {
     try
     {
         //Process Calculate Data
         m_bizProcess.calculateData(txtYear.IntValue, Util.ConvertObjectToInteger(cboMonth.SelectedValue), AppEnvironment.UserLogin);
     }
     catch (Exception ex)
     {
         AppEnvironment.CloseWaitForm();
         ExceptionManager.ManageException(this, ex);
     }
 }
コード例 #6
0
 private void btnProcess_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageDialog.ShowConfirmationMsg(this, "Do you want to pocess retrieve data?") == DialogButton.Yes)
         {
             ProcessData();
         }
     }
     catch (Exception ex)
     {
         AppEnvironment.CloseWaitForm();
         ExceptionManager.ManageException(this, ex);
     }
 }
コード例 #7
0
 private void btnRecal_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageDialog.ShowConfirmationMsg(this, "Do you want to re-calculate actual cost?") == DialogButton.Yes)
         {
             ProcessReCalculate();
         }
     }
     catch (Exception ex)
     {
         AppEnvironment.CloseWaitForm();
         ExceptionManager.ManageException(this, ex);
     }
 }
コード例 #8
0
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // Enable screen.
            SafeEnableControl(true, txtYear, cboMonth, cboSystem, btnClear, btnProcess);

            if (progressBar.Value == 100)
            {
                AppEnvironment.CloseWaitForm();
                MessageDialog.ShowInformationMsg("Process completed 100%");
                getRevision();
            }
            else
            {
                AppEnvironment.CloseWaitForm();
                MessageDialog.ShowInformationMsg("Process not completed.");
            }
        }
コード例 #9
0
        private void ProcessReCalculate()
        {
            if (!ValidateReCalRequire())
            {
                return;
            }

            //##################################
            //#Check process
            //##################################
            bool bRepeat = m_bizProcess.CheckRepeatProcess(txtYear.IntValue, Util.ConvertObjectToInteger(cboMonth.SelectedValue));

            if (!bRepeat)
            {
                MessageDialog.ShowBusinessErrorMsg(this, "Please Process Data First.");
                return;
            }

            if (Util.ConvertObjectToDecimal(txtActualCapacity.DecimalValue) != (Util.ConvertObjectToDecimal(txtSoldLiterSum.DecimalValue) + Util.ConvertObjectToDecimal(txtEndLiterSum.DecimalValue)))
            {
                MessageDialog.ShowBusinessErrorMsg(this, "Total FG Production is not equal to Total of Sold Liter and Ending Liter.");
                return;
            }

            AppEnvironment.ShowWaitForm("Please Wait", "Calculating");
            ProcessArgument arg = new ProcessArgument();

            arg.Year            = txtYear.IntValue;
            arg.Period          = Util.ConvertObjectToInteger(cboMonth.SelectedValue);
            arg.pActMOH         = Util.ConvertObjectToDecimal(txtActualMOH.DecimalValue);
            arg.pActCapaUsed    = Util.ConvertObjectToDecimal(txtActualCapacity.DecimalValue);
            arg.pSoldLiter      = Util.ConvertObjectToDecimal(txtSoldLiter.DecimalValue);
            arg.pEndingLiter    = Util.ConvertObjectToDecimal(txtEndLiter.DecimalValue);
            arg.pSoldLiterOEM   = Util.ConvertObjectToDecimal(txtSoldLiterOEM.DecimalValue);
            arg.pEndingLiterOEM = Util.ConvertObjectToDecimal(txtEndLiterOEM.DecimalValue);

            arg.ByUser = AppEnvironment.UserLogin;

            var resultDo = m_bizProcess.ReCalculateData(arg.Year, arg.Period, arg.pActMOH, arg.pActCapaUsed, arg.pSoldLiter, arg.pEndingLiter, arg.pSoldLiterOEM, arg.pEndingLiterOEM, arg.ByUser);

            UpdateReCalValue(resultDo);
            AppEnvironment.CloseWaitForm();
            MessageDialog.ShowInformationMsg("Calculate Completed");
        }
コード例 #10
0
ファイル: frmMainLogin.cs プロジェクト: EliGosK/LUBE-TECH
        /// <summary>
        /// แสดงหน้า Login
        /// </summary>
        public void PerformLogin()
        {
            frmLogin login = new frmLogin();

            login.Icon = AppEnvironment.AppIcon;

            if (login.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    // Show Working Form
                    InitialVariable();

                    frmMainMenu mainMenu = new frmMainMenu();
                    mainMenu.Icon = AppEnvironment.AppIcon;

                    mainMenu.MainLogin = this;
                    mainMenu.Show();


                    // Hide Background
                    this.Hide();
                }
                catch (Exception ex)
                {
                    AppEnvironment.CloseWaitForm();
                    ExceptionManager.ManageException(this, ex);

                    PerformLogin();
                }
            }
            else
            {
                // Exit Program
                this.Close();
            }
        }
コード例 #11
0
        private void importData()
        {
            try
            {
                if (!ValidateRequire())
                {
                    return;
                }

                FileInfo fiACS350 = new FileInfo(filePath);
                if (fiACS350.Exists)
                {
                    using (ExcelPackage excel = new ExcelPackage(fiACS350))
                    {
                        var sht = excel.Workbook.Worksheets[1];

                        //Check Format File
                        for (int i = 1; i <= 35; i++)
                        {
                            if (Util.IsNullOrEmpty(sht.Cells[4, i].Value))
                            {
                                MessageDialog.ShowBusinessErrorMsg(this, "Wrong File Format.");
                                return;
                            }
                        }

                        //Check No Data
                        if (Util.IsNullOrEmpty(sht.Cells[5, 1].Value))
                        {
                            MessageDialog.ShowBusinessErrorMsg(this, "There is no data perform operation.");
                            return;
                        }

                        //Check Exist Transfer
                        //bool isExist = m_bizProcess.CheckExistTransfer(txtYear.IntValue, Util.ConvertObjectToInteger(cboMonth.SelectedValue));
                        //if(isExist)
                        //{
                        //    MessageDialog.ShowBusinessErrorMsg(this, "This month can't be processed.");
                        //    return;
                        //}

                        AppEnvironment.ShowWaitForm("Please Wait", "Importing data");
                        //Delete data in InventoryRevalution_Imp table.
                        m_bizProcess.DeleteInventoryRevalution_Imp();

                        //Import data.
                        int lastRows = sht.Dimension.End.Row - 2; //last row of data import
                        DataImport.Year            = txtYear.IntValue;
                        DataImport.Period          = Util.ConvertObjectToInteger(cboMonth.SelectedValue);
                        DataImport.ActCapaUsed     = Util.ConvertObjectToDecimal(sht.Cells["AE2"].Value);
                        DataImport.EndingLiter     = Util.ConvertObjectToDecimal(sht.Cells["AE3"].Value);
                        DataImport.UnSoldBudgetAll = Util.ConvertObjectToDecimal(sht.Cells["AG2"].Value);
                        DataImport.UnSoldCapaAll   = Util.ConvertObjectToDecimal(sht.Cells["AH2"].Value);
                        DataImport.AdjInv          = Util.ConvertObjectToDecimal(sht.Cells["AH3"].Value);
                        DataImport.Lot1            = null; // Modified by Pachara S.

                        for (int i = 5; i <= lastRows; i++)
                        {
                            //countError = i;
                            if (Util.IsNullOrEmpty(sht.Cells[i, 1].Value))
                            {
                                break;
                            }

                            DataImport.PostingDate = ConvertObjectToDateTime(sht.Cells[i, 1].Value);
                            DataImport.BatchNo     = sht.Cells[i, 2].Text;
                            DataImport.ItemCode    = sht.Cells[i, 3].Text;
                            DataImport.BOM3        = sht.Cells[i, 4].Text;
                            DataImport.DocumentNo  = sht.Cells[i, 5].Text;
                            DataImport.Quantity    = Util.ConvertObjectToDecimal(sht.Cells[i, 6].Value);
                            DataImport.QTYPPKG     = Util.ConvertObjectToDecimal(sht.Cells[i, 7].Value);
                            DataImport.Liter       = Util.ConvertObjectToDecimal(sht.Cells[i, 8].Value);
                            DataImport.DueDate     = ConvertObjectToDateTime(sht.Cells[i, 9].Value);
                            //DataImport.Lot1 = sht.Cells[i, 10].Text; // Modified by Pachara S.
                            DataImport.DisAssemQty        = Util.ConvertObjectToDecimal(sht.Cells[i, 10].Value); // Modified by Pachara S.
                            DataImport.Ref2               = sht.Cells[i, 11].Text;
                            DataImport.BaseRef            = sht.Cells[i, 12].Text;
                            DataImport.RM_Cost_Cal        = Util.ConvertObjectToDecimal(sht.Cells[i, 13].Value);
                            DataImport.RM_Cost_B1_Display = Util.ConvertObjectToDecimal(sht.Cells[i, 14].Value);
                            DataImport.StdOH              = Util.ConvertObjectToDecimal(sht.Cells[i, 15].Value);
                            DataImport.Variance_BOM1      = Util.ConvertObjectToDecimal(sht.Cells[i, 16].Value);
                            DataImport.BOM1Cost           = Util.ConvertObjectToDecimal(sht.Cells[i, 17].Value);
                            DataImport.ContainerCost      = Util.ConvertObjectToDecimal(sht.Cells[i, 18].Value);
                            DataImport.LabelCost          = Util.ConvertObjectToDecimal(sht.Cells[i, 19].Value);
                            DataImport.ActualCostFG       = Util.ConvertObjectToDecimal(sht.Cells[i, 20].Value);
                            DataImport.Variance_BOM2      = Util.ConvertObjectToDecimal(sht.Cells[i, 21].Value);
                            DataImport.ReceiptQty         = Util.ConvertObjectToDecimal(sht.Cells[i, 22].Value);
                            DataImport.CalPrice           = Util.ConvertObjectToDecimal(sht.Cells[i, 23].Value);
                            DataImport.TransValue         = Util.ConvertObjectToDecimal(sht.Cells[i, 24].Value);
                            DataImport.WhsCode            = sht.Cells[i, 25].Text;
                            DataImport.SoldQuantity       = Util.ConvertObjectToDecimal(sht.Cells[i, 26].Value);
                            DataImport.SoldLiter          = Util.ConvertObjectToDecimal(sht.Cells[i, 27].Value);
                            DataImport.COGS               = Util.ConvertObjectToDecimal(sht.Cells[i, 28].Value);
                            DataImport.EndingBalQuantity  = Util.ConvertObjectToDecimal(sht.Cells[i, 29].Value);
                            DataImport.EndingBalLiter     = Util.ConvertObjectToDecimal(sht.Cells[i, 30].Value);
                            DataImport.Uprice             = Util.ConvertObjectToDecimal(sht.Cells[i, 31].Value);
                            DataImport.EndingBalAmount    = Util.ConvertObjectToDecimal(sht.Cells[i, 32].Value);
                            DataImport.Effect             = Util.ConvertObjectToDecimal(sht.Cells[i, 33].Value);
                            DataImport.NewAmount          = Util.ConvertObjectToDecimal(sht.Cells[i, 34].Value);
                            DataImport.NewPrice           = Util.ConvertObjectToDecimal(sht.Cells[i, 35].Value);

                            //Insert data in InventoryRevalution_Imp table.
                            m_bizProcess.InsertInventoryRevalution_Imp(DataImport);
                        }

                        //Check Posting Date not match
                        bool isNotMatch = m_bizProcess.CheckPostingDate(txtYear.IntValue, Util.ConvertObjectToInteger(cboMonth.SelectedValue));
                        if (isNotMatch)
                        {
                            AppEnvironment.CloseWaitForm();
                            MessageDialog.ShowBusinessErrorMsg(this, "Some Posting Date does not match with Selected Year/Month.");
                            return;
                        }

                        CalculateData();
                        AppEnvironment.CloseWaitForm();
                        MessageDialog.ShowInformationMsg("Import Completed.");
                    }
                }
            }
            catch (Exception ex)
            {
                AppEnvironment.CloseWaitForm();
                ExceptionManager.ManageException(this, ex);
            }
        }
コード例 #12
0
        private void ProcessData()
        {
            //##################################
            // 1. Check mandatory data
            //   Year, Month, System
            //##################################
            if (!ValidateRequire())
            {
                return;
            }

            int Year   = txtYear.IntValue;
            int Period = Util.ConvertObjectToInteger(cboMonth.SelectedValue);

            //##################################
            //# 2. Check data transfer to SAP B1
            //##################################
            bool bExistTransfer = m_bizProcess.CheckExistTransfer(Year, Period);

            if (bExistTransfer)
            {
                MessageDialog.ShowBusinessErrorMsg(this, "This month can't be processed");
                return;
            }

            //##################################
            //# 3. Check retrieve data from SAP B1
            //##################################
            bool bRetrieveData = m_bizProcess.CheckRetrieve(Year, Period);

            if (!bRetrieveData)
            {
                MessageDialog.ShowBusinessErrorMsg(this, "Please Retrieve data before Calculation");
                return;
            }

            //##################################
            //# 4. Check repeat process
            //##################################
            bool bRepeat = m_bizProcess.CheckRepeatProcess(Year, Period);

            if (bRepeat)
            {
                if (MessageDialog.ShowConfirmationMsg(this, "Do you want to do repeat process?") == DialogButton.No)
                {
                    return;
                }
            }

            //##################################
            //# 5. Start Process Calculation (Async)
            //##################################
            AppEnvironment.ShowWaitForm("Please Wait", "Processing");
            ProcessArgument argument = new ProcessArgument();

            argument.Year   = Year;
            argument.Period = Period;
            argument.ByUser = AppEnvironment.UserLogin;

            bgWorkerProcess.RunWorkerAsync(argument);

            while (bgWorkerProcess.IsBusy)
            {
                Thread.Sleep(200);
                Application.DoEvents();
            }

            //##################################
            //# 7. Show information message after process complete.
            //##################################
            tb_Transfer transferResult = null;

            if (progressBar.Value == 100)
            {
                AppEnvironment.CloseWaitForm();
                MessageDialog.ShowInformationMsg("Process completed 100%");
                //transferResult = m_bizProcess.GetTransferData(Year, Period);
            }
            else
            {
                AppEnvironment.CloseWaitForm();
                MessageDialog.ShowInformationMsg("Process not completed.");
            }

            //##################################
            //# 8. Display output after process complete.
            //##################################
            //if (transferResult == null)
            //{
            //    txtActualMOH.Text = string.Empty;
            //    txtActualCapacity.Text = string.Empty;
            //    txtActualMOHRate.Text = string.Empty;
            //}
            //else
            //{
            //    txtActualMOH.DecimalValue = transferResult.ActualMOH.GetValueOrDefault(0);
            //    txtActualCapacity.DecimalValue = transferResult.ActualCapacity.GetValueOrDefault(0);
            //    txtActualMOHRate.DecimalValue = transferResult.ActualMOHRate.GetValueOrDefault(0);
            //}
        }
コード例 #13
0
        private void Process()
        {
            try
            {
                if (!ValidateRequire())
                {
                    return;
                }

                //bool isExist = m_bizProcess.CheckExistTransfer(year, period);
                //if(isExist)
                //{
                //    MessageDialog.ShowBusinessErrorMsg(this, "This month can't be processed");
                //    return;
                //}

                AppEnvironment.ShowWaitForm("Please Wait", "Connecting to SAP B1.");

                SAPCompany company = null;
                Console.WriteLine("Start Connect SAP B1");
                company = NECT_EDI.SAP.SAPCompany.InitializeCompany(connection, out errorMsg);
                if (company == null)
                {
                    AppEnvironment.CloseWaitForm();
                    MessageDialog.ShowBusinessErrorMsg(this, "Cannot connect to SAP B1.");
                    return;
                }

                AppEnvironment.ShowWaitForm("Please Wait", "Processing");

                //Journal Voucher
                DataTable dtJV = m_bizProcess.GetJournalEntryData(year, period);
                if (!Util.IsNullOrEmptyOrZero(dtJV.Rows.Count))
                {
                    foreach (DataRow row in dtJV.Rows)
                    {
                        dtJVRefDate          = DateTime.Parse(row["RefDate"].ToString());
                        dtJVTaxDate          = DateTime.Parse(row["TaxDate"].ToString());
                        dtJVDueDate          = DateTime.Parse(row["DueDate"].ToString());
                        strBG_Dr_LT_AccCode  = row["BG_Dr_LT_AccCode"].ToString();
                        dBG_Dr_LT_Value      = Util.ConvertObjectToDouble(row["BG_Dr_LT_Value"].ToString());
                        strBG_Dr_OEM_AccCode = row["BG_Dr_OEM_AccCode"].ToString();
                        dBG_Dr_OEM_Value     = Util.ConvertObjectToDouble(row["BG_Dr_OEM_Value"].ToString());
                        strBG_Cr_LT_AccCode  = row["BG_Cr_LT_AccCode"].ToString();
                        dBG_Cr_LT_Value      = Util.ConvertObjectToDouble(row["BG_Cr_LT_Value"].ToString());
                        strBG_Cr_OEM_AccCode = row["BG_Cr_OEM_AccCode"].ToString();
                        dBG_Cr_OEM_Value     = Util.ConvertObjectToDouble(row["BG_Cr_OEM_Value"].ToString());
                        strCP_Dr_LT_AccCode  = row["CP_Dr_LT_AccCode"].ToString();
                        dCP_Dr_LT_Value      = Util.ConvertObjectToDouble(row["CP_Dr_LT_Value"].ToString());
                        strCP_Dr_OEM_AccCode = row["CP_Dr_OEM_AccCode"].ToString();
                        dCP_Dr_OEM_Value     = Util.ConvertObjectToDouble(row["CP_Dr_OEM_Value"].ToString());
                        strCP_Cr_LT_AccCode  = row["CP_Cr_LT_AccCode"].ToString();
                        dCP_Cr_LT_Value      = Util.ConvertObjectToDouble(row["CP_Cr_LT_Value"].ToString());
                        strCP_Cr_OEM_AccCode = row["CP_Cr_OEM_AccCode"].ToString();
                        dCP_Cr_OEM_Value     = Util.ConvertObjectToDouble(row["CP_Cr_OEM_Value"].ToString());

                        NECT_EDI.SAP.SAPCompany.JV(dtJVRefDate, dtJVTaxDate, dtJVDueDate, strBG_Dr_LT_AccCode, dBG_Dr_LT_Value, strBG_Dr_OEM_AccCode, dBG_Dr_OEM_Value,
                                                   strBG_Cr_LT_AccCode, dBG_Cr_LT_Value, strBG_Cr_OEM_AccCode, dBG_Cr_OEM_Value, strCP_Dr_LT_AccCode, dCP_Dr_LT_Value,
                                                   strCP_Dr_OEM_AccCode, dCP_Dr_OEM_Value, strCP_Cr_LT_AccCode, dCP_Cr_LT_Value, strCP_Cr_OEM_AccCode, dCP_Cr_OEM_Value, out errorMsg);

                        if (!Util.IsNullOrEmpty(errorMsg))
                        {
                            AppEnvironment.CloseWaitForm();
                            MessageDialog.ShowBusinessErrorMsg(this, errorMsg);
                            return;
                        }
                        else
                        {
                            m_bizProcess.UpdateProcessControl_JV(year, period, AppEnvironment.UserLogin);
                        }
                    }
                }

                //Inventory Revaluation
                DataTable dt = m_bizProcess.GetInventoryRevaluationData(year, period);

                if (!Util.IsNullOrEmptyOrZero(dt.Rows.Count))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        dtDocDate = DateTime.Parse(row["PostingDate"].ToString());
                        dtTaxDate = DateTime.Parse(row["TaxDate"].ToString());
                        strRef2   = row["BatchNo"].ToString();

                        if (Util.IsNullOrEmptyOrZero(row["Series"].ToString()))
                        {
                            iSeries = null;
                        }
                        else
                        {
                            iSeries = Convert.ToInt32(row["Series"].ToString());
                        }

                        strComment   = row["Comment"].ToString();
                        strJrnMemo   = row["JrnMemo"].ToString();
                        strItemCode  = row["ItemCode"].ToString();
                        strWhsCode   = row["WhsCode"].ToString();
                        strRevalInc  = row["RevalInc"].ToString();
                        strRevalDec  = row["RevalDec"].ToString();
                        iSnbAbsEntry = Convert.ToInt32(row["AbsEntry"].ToString());
                        dNewCost     = Convert.ToDouble(row["NewPrice"].ToString());

                        NECT_EDI.SAP.SAPCompany.InventoryRevaluation(dtDocDate, dtTaxDate, strRef2, iSeries, strComment, strJrnMemo, strItemCode, strWhsCode,
                                                                     strRevalInc, strRevalDec, iSnbAbsEntry, dNewCost, out errorMsg);

                        if (!Util.IsNullOrEmpty(errorMsg))
                        {
                            AppEnvironment.CloseWaitForm();
                            MessageDialog.ShowBusinessErrorMsg(this, errorMsg);
                            return;
                        }
                        else
                        {
                            m_bizProcess.UpdateProcessControl(year, period, strItemCode, strRef2, AppEnvironment.UserLogin);
                        }
                    }

                    AppEnvironment.CloseWaitForm();
                    MessageDialog.ShowInformationMsg("Process completed 100%");
                }
            }
            catch (Exception ex)
            {
                AppEnvironment.CloseWaitForm();
                ExceptionManager.ManageException(this, ex);
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: EliGosK/LUBE-TECH
        static void Main(string[] args)
        {
            //####################
            //# Set Look and Feel
            //####################
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //== Update config from Auto Update ===================
            //if (args.Length > 0)
            //{
            //    string[] arrParam = args[0].ToString().Split('|');
            //    string strParam1 = string.Empty;
            //    if (arrParam.Length > 0)
            //    {
            //        XmlConfiguration inc = new XmlConfiguration();
            //        strParam1 = arrParam[1];
            //        if (args.Length > 1)
            //        {
            //            for (int i = 1; i < args.Length; i++)
            //            {
            //                strParam1 = strParam1 + " " + args[i].ToString();
            //            }
            //        }

            //        inc.SetValue(arrParam[0], strParam1);
            //    }
            //    return;
            //}


            if (PriorProcess() != null)
            {
                MessageDialog.Show(null, "Exception", "Application has running already.", null, MessageBoxIcon.Stop, DialogButton.OK);
                return;
            }


#if !DEBUG
            //####################
            //# Run AutoUpdate
            //####################
            if (args.Length == 0)
            {
                if (RunAutoUpdate())
                {
                    // Terminate Application.
                    return;
                }
            }
            else if (args.Length == 1)
            {
                //  argument muet be "SkipUpdate" if not it will dislay error
                if (args[0].ToLower() != "SkipUpdate".ToLower())
                {
                    MessageDialog.ShowInformationMsg("Application's argument must be \"SkipUpdate\" or not input");
                    return;
                }
            }
#endif

            //####################
            //# Load configuration
            //####################
            InitialApplication();

            try
            {
                #region Test SplashScreen

                //SplashScreen sp = new SplashScreen(typeof(WaitFormProgress));
                //sp.Caption = "Please Wait";
                //sp.Description = "Value: 0";
                //sp.ShowSplashScreen();


                //if (sp.IsVisibleSplashScreen)
                //{
                //    WaitFormProgress wf = (WaitFormProgress)sp.WaitForm;
                //    wf.ResizeMode = eResizeMode.GrowOnly;

                //    int i = 0;
                //    while (i <= 100)
                //    {
                //        string lineDesc = "Value: " + i + Environment.NewLine + "Line 1";
                //        if (i % 2 == 0)
                //        {
                //            lineDesc += Environment.NewLine + "Line 2";
                //        }



                //        wf.SetDescription(lineDesc);
                //        wf.SetProgressValue(i);
                //        Thread.Sleep(50);

                //        i++;
                //    }
                //}

                //sp.CloseSplashScreen();

                #endregion



                AppEnvironment.ShowWaitForm("Please Wait", "Initializing Report.");
                //####################
                //# Silent load report
                //####################
                SilentLoadReport();

                //####################
                //# Test Database Connection
                //####################
                AppEnvironment.ShowWaitForm("Please Wait", "Connecting to database server.");
                if (!TestConnection())
                {
                    //AppEnvironment.CloseWaitForm();
                    MessageDialog.ShowBusinessErrorMsg(null, "Cannot connect to database. Please contact Administrator.");
                    GC.Collect();
                    return;
                }

                //####################
                //# Load Global Message
                //####################
                /* MessageManager used by Util class */
                AppEnvironment.ShowWaitForm("Please Wait", "Preparing Message");


                CommonBIZ bizCommon   = new CommonBIZ();
                DataTable dtbMessages = bizCommon.GetAllMessage();
                MessageManager.SetMessage(dtbMessages);

                //####################
                //# Permission
                //####################
                AppEnvironment.Permission = new PermissionBIZ();
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(null, ex);
            }
            finally
            {
                AppEnvironment.CloseWaitForm();
            }

            frmMainLogin mainLogin = new frmMainLogin();
            mainLogin.Icon = AppEnvironment.AppIcon;

            AppEnvironment.MainLoginForm = mainLogin;
            Application.Run(mainLogin);
        }