Example #1
0
        public void Execute()
        {
            if (ValidateModule())
            {
                LockUserAction();

                new WorkerThread(
                    delegate
                {
                    try
                    {
                        using (var ctrlSA = new SAController())
                        {
                            List <string> values;
                            var repeatInput         = false;
                            DataContainer container = null;
                            switch (ModuleInfo.SubModule)
                            {
                            case CODES.DEFMOD.SUBMOD.MAINTAIN_ADD:
                                if (MaintainInfo.Report == "Y")
                                {
                                    try
                                    {
                                        P();
                                    }
                                    catch (Exception ex)
                                    {
                                        ShowError(ex);
                                    }
                                }
                                else
                                {
                                    GetOracleParameterValues(out values, MaintainInfo.AddInsertStore);
                                    List <string> temp = new List <string>();
                                    //TUDQ them
                                    if (MaintainInfo.ModuleID == "02913")
                                    {
                                        foreach (string value in values)
                                        {
                                            temp.Add(CommonUtils.EncryptStringBySHA1(value));
                                        }
                                        values = temp;
                                    }
                                    if (MaintainInfo.TRANSACTION_MODE == "Y")
                                    {
                                        values[values.Count - 1] = MaintainInfo.ModuleID;
                                        values.Add(null);
                                    }
                                    //END
                                    ctrlSA.ExecuteMaintain(out container, ModuleInfo.ModuleID, ModuleInfo.SubModule, values);
                                }
                                if (MaintainInfo.AddRepeatInput == CODES.MODMAINTAIN.REPEATINPUT.YES)
                                {
                                    repeatInput = true;
                                }
                                break;

                            case CODES.DEFMOD.SUBMOD.MAINTAIN_EDIT:
                                GetOracleParameterValues(out values, MaintainInfo.EditUpdateStore);
                                ctrlSA.ExecuteMaintain(out container, ModuleInfo.ModuleID, ModuleInfo.SubModule, values);

                                if (MaintainInfo.EditRepeatInput == CODES.MODMAINTAIN.REPEATINPUT.YES)
                                {
                                    repeatInput = true;
                                }
                                break;

                            case CODES.DEFMOD.SUBMOD.MAINTAIN_VIEW:
                                try
                                {
                                    // Lay thong tin module trong tllog
                                    List <string> value = new List <string>();
                                    string v_Submod     = null;
                                    value.Add(Program.txnum);
                                    ctrlSA.ExecuteProcedureFillDataset(out container, "sp_tllog_sel_basic", value);
                                    if (container != null && container.DataTable != null)
                                    {
                                        var resultTable = container.DataTable;
                                        if (resultTable.Rows.Count > 0)
                                        {
                                            v_Submod = resultTable.Rows[0]["SUBMOD"].ToString();
                                        }
                                    }

                                    if (v_Submod == CODES.DEFMOD.SUBMOD.MAINTAIN_ADD)
                                    {
                                        GetOracleParameterValues(out values, MaintainInfo.AddInsertStore);
                                        ctrlSA.ExecApprove(out container, ModuleInfo.ModuleID, v_Submod, SecID, values);

                                        // Cap nhat tllogs
                                        List <string> valueAcceptTrans = new List <string>();
                                        valueAcceptTrans.Add(Program.txnum);
                                        valueAcceptTrans.Add(App.Environment.ClientInfo.UserName);
                                        ctrlSA.ExecuteStoreProcedure("sp_accept_trans", valueAcceptTrans);

                                        List <string> values1 = new List <string>();
                                        values1.Add(null);
                                        values1.Add(Program.txnum);
                                        // Cap nhat file dinh kem vao bang Bussiness tuong ung
                                        if (!string.IsNullOrEmpty(MaintainInfo.EXECTRANSCTIONSTORE))
                                        {
                                            ctrlSA.ExecuteStoreProcedure(MaintainInfo.EXECTRANSCTIONSTORE, values1);
                                        }
                                        Program.txnum = null;
                                    }
                                    else if (v_Submod == CODES.DEFMOD.SUBMOD.MAINTAIN_EDIT)
                                    {
                                        GetOracleParameterValues(out values, MaintainInfo.EditUpdateStore);
                                        string v_ROWID = values[0].ToString();

                                        List <string> values1 = new List <string>();
                                        values1.Add(v_ROWID);
                                        values1.Add(Program.txnum);
                                        // Duyet thong tin
                                        ctrlSA.ExecApprove(out container, ModuleInfo.ModuleID, v_Submod, SecID, values);

                                        // Cap nhat tllogs
                                        List <string> valueAcceptTrans = new List <string>();
                                        valueAcceptTrans.Add(Program.txnum);
                                        valueAcceptTrans.Add(App.Environment.ClientInfo.UserName);
                                        ctrlSA.ExecuteStoreProcedure("sp_accept_trans", valueAcceptTrans);

                                        // Cap nhat file dinh kem vao bang Bussiness tuong ung
                                        if (!string.IsNullOrEmpty(MaintainInfo.EXECTRANSCTIONSTORE))
                                        {
                                            ctrlSA.ExecuteStoreProcedure(MaintainInfo.EXECTRANSCTIONSTORE, values1);
                                        }
                                        Program.txnum = null;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ShowError(ex);
                                    UnLockUserAction();
                                }
                                break;

                            //end trungtt
                            case CODES.DEFMOD.SUBMOD.TRANSACTION_VIEW:
                                try
                                {
                                    List <string> values1 = new List <string>();
                                    values1.Add(Program.txnum);
                                    values1.Add(ModuleInfo.ModuleID);
                                    values1.Add(App.Environment.ClientInfo.UserName);
                                    ctrlSA.ExecuteStoreProcedure(MaintainInfo.EXECTRANSCTIONSTORE, values1);
                                    repeatInput = false;
                                }
                                catch (Exception ex)
                                {
                                    ShowError(ex);
                                    UnLockUserAction();
                                }
                                break;
                            }

                            RequireRefresh = true;

                            if (MaintainInfo.ShowSuccess == CODES.MODMAINTAIN.SHOWSUCCESS.YES)
                            {
                                RowFormattable fmtRow = null;

                                if (container != null)
                                {
                                    var rows = container.DataTable.Rows;
                                    if (rows.Count == 1)
                                    {
                                        fmtRow = new RowFormattable(rows[0]);
                                    }
                                }

                                if (fmtRow != null)
                                {
                                    frmInfo.ShowInfo(Language.Title, string.Format(Language.SuccessStatus, fmtRow), this);
                                }
                                else
                                {
                                    frmInfo.ShowInfo(Language.Title, Language.SuccessStatus, this);
                                }
                            }

                            if (!repeatInput)
                            {
                                CloseModule();
                            }
                            else
                            {
                                ResetModuleData();
                                UnLockUserAction();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowError(ex);
                        UnLockUserAction();
                    }
                }, this).Start();
            }
        }