Exemple #1
0
        private void PrepareEditView()
        {
            PRMSupplierEntity pRMSupplierEntity = CurrentPRMSupplierEntity;


            if (!pRMSupplierEntity.IsNew)
            {
                txtSupplierCode.Text = pRMSupplierEntity.SupplierCode.ToString();
                txtSupplierName.Text = pRMSupplierEntity.SupplierName.ToString();
                txtRelationship.Text = pRMSupplierEntity.Relationship.ToString();
                txtPhone.Text        = pRMSupplierEntity.Phone.ToString();
                txtMobileNo.Text     = pRMSupplierEntity.MobileNo.ToString();
                txtFax.Text          = pRMSupplierEntity.Fax.ToString();
                txtEmail.Text        = pRMSupplierEntity.Email.ToString();
                txtWebLink.Text      = pRMSupplierEntity.WebLink.ToString();
                txtCreateDate.Text   = pRMSupplierEntity.CreateDate.ToStringDefault();

                if (ddlSupplierTypeID.Items.Count > 0 && pRMSupplierEntity.SupplierTypeID != null)
                {
                    ddlSupplierTypeID.SelectedValue = pRMSupplierEntity.SupplierTypeID.ToString();
                }

                if (ddlSupplierStatusID.Items.Count > 0 && pRMSupplierEntity.SupplierStatusID != null)
                {
                    ddlSupplierStatusID.SelectedValue = pRMSupplierEntity.SupplierStatusID.ToString();
                }

                txtReason.Text       = pRMSupplierEntity.Reason.ToString();
                txtRemarks.Text      = pRMSupplierEntity.Remarks.ToString();
                chkIsRemoved.Checked = pRMSupplierEntity.IsRemoved;

                btnSubmit.Text = "Update";
            }
        }
Exemple #2
0
        Int64 IPRMSupplierDataAccess.Add(PRMSupplierEntity pRMSupplierEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(pRMSupplierEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(pRMSupplierEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        private void SavePRMSupplierEntity()
        {
            if (IsValid)
            {
                try
                {
                    PRMSupplierEntity pRMSupplierEntity = BuildPRMSupplierEntity();

                    Int64 result = -1;

                    if (pRMSupplierEntity.IsNew)
                    {
                        result = FCCPRMSupplier.GetFacadeCreate().Add(pRMSupplierEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierEntity.FLD_NAME_SupplierID, pRMSupplierEntity.SupplierID.ToString(), SQLMatchType.Equal);
                        result = FCCPRMSupplier.GetFacadeCreate().Update(pRMSupplierEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        String NavUrl = UrlHelper.BuildSecureUrl("~/PRM/PRMSupplierEditor.aspx", string.Empty, UrlConstants.OVERVIEW_SUPPLIER_ID, result.ToString()).ToString();

                        Response.Redirect(NavUrl);

                        _SupplierID        = 0;
                        _PRMSupplierEntity = new PRMSupplierEntity();
                        PrepareInitialView();
                        BindPRMSupplierList();

                        if (pRMSupplierEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Vendor Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Vendor Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (pRMSupplierEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Vendor Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Vendor Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemple #4
0
        private void SavePRMSupplierEntity()
        {
            if (IsValid)
            {
                try
                {
                    PRMSupplierEntity pRMSupplierEntity = BuildPRMSupplierEntity();

                    Int64 result = -1;

                    if (pRMSupplierEntity.IsNew)
                    {
                        result = FCCPRMSupplier.GetFacadeCreate().Add(pRMSupplierEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierEntity.FLD_NAME_SupplierID, pRMSupplierEntity.SupplierID.ToString(), SQLMatchType.Equal);
                        result = FCCPRMSupplier.GetFacadeCreate().Update(pRMSupplierEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _SupplierID        = 0;
                        _PRMSupplierEntity = new PRMSupplierEntity();
                        PrepareInitialView();
                        BindPRMSupplierList();

                        if (pRMSupplierEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Vendor Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Vendor Information has been updated successfully.", false);
                        }
                        PrepareEditView();
                    }
                    else
                    {
                        if (pRMSupplierEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Vendor Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Vendor Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemple #5
0
        private Int64 Update(PRMSupplierEntity pRMSupplierEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplier_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierEntity.SupplierID);
                Database.AddInParameter(cmd, "@SupplierCode", DbType.String, pRMSupplierEntity.SupplierCode);
                Database.AddInParameter(cmd, "@SupplierName", DbType.String, pRMSupplierEntity.SupplierName);
                Database.AddInParameter(cmd, "@Relationship", DbType.String, pRMSupplierEntity.Relationship);
                Database.AddInParameter(cmd, "@Phone", DbType.String, pRMSupplierEntity.Phone);
                Database.AddInParameter(cmd, "@MobileNo", DbType.String, pRMSupplierEntity.MobileNo);
                Database.AddInParameter(cmd, "@Fax", DbType.String, pRMSupplierEntity.Fax);
                Database.AddInParameter(cmd, "@Email", DbType.String, pRMSupplierEntity.Email);
                Database.AddInParameter(cmd, "@WebLink", DbType.String, pRMSupplierEntity.WebLink);
                Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, pRMSupplierEntity.CreateDate);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, pRMSupplierEntity.Remarks);
                Database.AddInParameter(cmd, "@SupplierTypeID", DbType.Int64, pRMSupplierEntity.SupplierTypeID);
                Database.AddInParameter(cmd, "@SupplierStatusID", DbType.Int64, pRMSupplierEntity.SupplierStatusID);
                Database.AddInParameter(cmd, "@Reason", DbType.String, pRMSupplierEntity.Reason);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, pRMSupplierEntity.IsRemoved);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("PRMSupplierEntity already exists. Please specify another PRMSupplierEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMSupplierEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMSupplierEntity already exists. Please specify another PRMSupplierEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
Exemple #6
0
        protected void lvPRMSupplier_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 SupplierID;

            Int64.TryParse(e.CommandArgument.ToString(), out SupplierID);

            if (SupplierID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _SupplierID = SupplierID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierEntity.FLD_NAME_SupplierID, SupplierID.ToString(), SQLMatchType.Equal);

                        PRMSupplierEntity pRMSupplierEntity = new PRMSupplierEntity();


                        result = FCCPRMSupplier.GetFacadeCreate().Delete(pRMSupplierEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _SupplierID        = 0;
                            _PRMSupplierEntity = new PRMSupplierEntity();
                            PrepareInitialView();
                            BindPRMSupplierList();

                            MiscUtil.ShowMessage(lblMessage, "Vendor has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Vendor.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Exemple #7
0
        private Int64 DeleteTran(PRMSupplierEntity pRMSupplierEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplier_SET";

            Database db = DatabaseFactory.CreateDatabase();


            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);


                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode >= 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
Exemple #8
0
        private PRMSupplierEntity BuildPRMSupplierEntity()
        {
            PRMSupplierEntity pRMSupplierEntity = CurrentPRMSupplierEntity;

            pRMSupplierEntity.SupplierCode = txtSupplierCode.Text.Trim();
            pRMSupplierEntity.SupplierName = txtSupplierName.Text.Trim();
            pRMSupplierEntity.Relationship = txtRelationship.Text.Trim();
            pRMSupplierEntity.Phone        = txtPhone.Text.Trim();
            pRMSupplierEntity.MobileNo     = txtMobileNo.Text.Trim();
            pRMSupplierEntity.Fax          = txtFax.Text.Trim();
            pRMSupplierEntity.Email        = txtEmail.Text.Trim();
            pRMSupplierEntity.WebLink      = txtWebLink.Text.Trim();
            if (txtCreateDate.Text.Trim().IsNotNullOrEmpty())
            {
                pRMSupplierEntity.CreateDate = MiscUtil.ParseToDateTime(txtCreateDate.Text);
            }

            if (ddlSupplierTypeID.Items.Count > 0)
            {
                if (ddlSupplierTypeID.SelectedValue == "0")
                {
                }
                else
                {
                    pRMSupplierEntity.SupplierTypeID = Int64.Parse(ddlSupplierTypeID.SelectedValue);
                }
            }

            if (ddlSupplierStatusID.Items.Count > 0)
            {
                if (ddlSupplierStatusID.SelectedValue == "0")
                {
                }
                else
                {
                    pRMSupplierEntity.SupplierStatusID = Int64.Parse(ddlSupplierStatusID.SelectedValue);
                }
            }

            pRMSupplierEntity.Remarks   = txtRemarks.Text.Trim();
            pRMSupplierEntity.Reason    = txtReason.Text.Trim();
            pRMSupplierEntity.IsRemoved = chkIsRemoved.Checked;

            return(pRMSupplierEntity);
        }
        private void BuildModelLabel()
        {
            PRMSupplierEntity pmrSupplierEntity = CurrentPRMSupplierEntity;

            if (pmrSupplierEntity != null && pmrSupplierEntity.SupplierID > 0)
            {
                switch (pmrSupplierEntity.SupplierTypeID)
                {
                case MasterDataConstants.MDSupplierType.CONTRACTOR:
                case MasterDataConstants.MDSupplierType.CONSULTANT:
                    lblModel.Text = "Experties";
                    break;

                default:
                    lblModel.Text = "Model";
                    break;
                }
            }
        }
Exemple #10
0
        private Int64 Delete(PRMSupplierEntity pRMSupplierEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplier_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);


                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("PRMSupplierEntity already exists. Please specify another PRMSupplierEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMSupplierEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMSupplierEntity already exists. Please specify another PRMSupplierEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
Exemple #11
0
        protected void lvPRMSupplier_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 SupplierID;

            Int64.TryParse(e.CommandArgument.ToString(), out SupplierID);

            if (SupplierID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierEntity.FLD_NAME_SupplierID, SupplierID.ToString(), SQLMatchType.Equal);

                        PRMSupplierEntity pRMSupplierEntity = new PRMSupplierEntity();


                        result = FCCPRMSupplier.GetFacadeCreate().Delete(pRMSupplierEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                        }
                        else
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Exemple #12
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _SupplierID        = 0;
     _PRMSupplierEntity = new PRMSupplierEntity();
     PrepareInitialView();
 }
 Int64 IPRMSupplierFacade.Add(PRMSupplierEntity pRMSupplierEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMSupplierDataAccess().Add(pRMSupplierEntity, option, reqTran));
 }
 Int64 IPRMSupplierFacade.Delete(PRMSupplierEntity pRMSupplierEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMSupplierDataAccess().Delete(pRMSupplierEntity, filterExpression, option, reqTran));
 }
        protected void lvACCPrePayableStatementDetail_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                ListViewDataItem dataItem = (ListViewDataItem)e.Item;

                ACCPostPayableStatementDetailEntity ent = (ACCPostPayableStatementDetailEntity)dataItem.DataItem;

                Label        lblProjectNameLV                            = (Label)e.Item.FindControl("lblProjectNameLV");
                Label        lblVendorCategoryNameLV                     = (Label)e.Item.FindControl("lblVendorCategoryNameLV");
                Label        lblVendorCategoryIDLV                       = (Label)e.Item.FindControl("lblVendorCategoryIDLV");
                Label        lblVendorIDLV                               = (Label)e.Item.FindControl("lblVendorIDLV");
                Label        lblVendorNameLV                             = (Label)e.Item.FindControl("lblVendorNameLV");
                Label        lblProjectIDLV                              = (Label)e.Item.FindControl("lblProjectIDLV");
                DropDownList ddlACCPayableApprovalStatusIDLV             = (DropDownList)e.Item.FindControl("ddlACCPayableApprovalStatusIDLV");
                DropDownList ddlACCPayablePaymentStatusIDLV              = (DropDownList)e.Item.FindControl("ddlACCPayablePaymentStatusIDLV");
                DropDownList ddlPayableClassificationIDLV                = (DropDownList)e.Item.FindControl("ddlPayableClassificationIDLV");
                DropDownList ddlAccountPaybleStatementDetailCategoryIDLV = (DropDownList)e.Item.FindControl("ddlAccountPaybleStatementDetailCategoryIDLV");
                CheckBox     chkPartyReconcileLV                         = (CheckBox)e.Item.FindControl("chkPartyReconcileLV");

                if (lblProjectIDLV != null)
                {
                    BDProjectEntity _bDProjectEntity = FCCBDProject.GetFacadeCreate().GetByID(Int64.Parse(lblProjectIDLV.Text));

                    if (_bDProjectEntity != null)
                    {
                        lblProjectNameLV.Text = _bDProjectEntity.ProjectName + " (" + _bDProjectEntity.ProjectCode + ")";
                    }
                }

                MiscUtil.PopulateMDACCPayablePaymentStatus(ddlACCPayablePaymentStatusIDLV, false);
                MiscUtil.PopulateMDACCPayableApprovalStatus(ddlACCPayableApprovalStatusIDLV, false);
                MiscUtil.PopulateMDPayableClassification(ddlPayableClassificationIDLV, false);
                MiscUtil.PopulateMDAccountPaybleStatementDetailCategory(ddlAccountPaybleStatementDetailCategoryIDLV, false);
                _PostPayableStatementDetailID = ent.PostPayableStatementDetailID;

                if (ent.PartyReconcile == true)
                {
                    chkPartyReconcileLV.Checked = true;
                }
                else
                {
                    chkPartyReconcileLV.Checked = false;
                }

                Int64 vendorID;
                Int64.TryParse(lblVendorIDLV.Text.ToString(), out vendorID);

                switch (lblVendorCategoryIDLV.Text)
                {
                case MasterDataConstants.CM_Bill_VendorCategory.CONSULTANT:
                    CMConsultantEntity _cmConsultantEntity = FCCCMConsultant.GetFacadeCreate().GetByID(vendorID);
                    lblVendorCategoryNameLV.Text = "CONSULTANT";
                    lblVendorNameLV.Text         = _cmConsultantEntity.Name;
                    break;

                case MasterDataConstants.CM_Bill_VendorCategory.CONTRACTOR:
                    CMContractorEntity _cMContractorEntity = FCCCMContractor.GetFacadeCreate().GetByID(vendorID);
                    lblVendorCategoryNameLV.Text = "CONTRACTOR";
                    lblVendorNameLV.Text         = _cMContractorEntity.Name;
                    break;

                case MasterDataConstants.CM_Bill_VendorCategory.VENDOR:
                    PRMSupplierEntity _pRMSupplierEntity = FCCPRMSupplier.GetFacadeCreate().GetByID(vendorID);
                    lblVendorCategoryNameLV.Text = "VENDOR";
                    lblVendorNameLV.Text         = _pRMSupplierEntity.SupplierName;
                    break;
                }

                if (ddlACCPayableApprovalStatusIDLV != null && ddlACCPayableApprovalStatusIDLV.Items.Count > 0)
                {
                    ddlACCPayableApprovalStatusIDLV.SelectedValue = ent.ACCPayableApprovalStatusID.ToString();
                }

                if (ddlACCPayablePaymentStatusIDLV != null && ddlACCPayablePaymentStatusIDLV.Items.Count > 0)
                {
                    ddlACCPayablePaymentStatusIDLV.SelectedValue = ent.ACCPayablePaymentStatusID.ToString();
                }

                if (ddlPayableClassificationIDLV != null && ddlPayableClassificationIDLV.Items.Count > 0)
                {
                    ddlPayableClassificationIDLV.SelectedValue = ent.PayableClassificationID.ToString();
                }

                if (ddlAccountPaybleStatementDetailCategoryIDLV != null && ddlAccountPaybleStatementDetailCategoryIDLV.Items.Count > 0)
                {
                    ddlAccountPaybleStatementDetailCategoryIDLV.SelectedValue = ent.AccountPaybleStatementDetailCategoryID.ToString();
                }

                ddlACCPayableApprovalStatusIDLV.Enabled = false;
            }
        }
        protected void btnMakePayment_Click(object sender, EventArgs e)
        {
            try
            {
                IList <ListViewDataItem> list = lvACCPrePayableStatementDetail.Items;

                if (list != null && list.Count > 0)
                {
                    Int32 tempDataItemIndex = 0;

                    foreach (ListViewDataItem lvdi in list)
                    {
                        DataKey currentDataKey = lvACCPrePayableStatementDetail.DataKeys[tempDataItemIndex++];
                        Int64   _postPayableStatementDetailID = (Int64)currentDataKey["PostPayableStatementDetailID"];
                        _PostPayableStatementDetailID = _postPayableStatementDetailID;
                    }
                }
            }
            catch (Exception ex)
            {
            }

            if (_PostPayableStatementDetailID > 0)
            {
                ACCPostPayableStatementDetailEntity aCCPostPayableStatementDetailEntity = CurrentACCPostPayableStatementDetailEntity;

                if (aCCPostPayableStatementDetailEntity != null && aCCPostPayableStatementDetailEntity.PostPayableStatementDetailID > 0)
                {
                    txtAmount.Text = aCCPostPayableStatementDetailEntity.NetPayableConsideringBillAndSecurity.ToString();

                    PRMSupplierEntity pRMSupplierEntity = FCCPRMSupplier.GetFacadeCreate().GetByID(aCCPostPayableStatementDetailEntity.FromVendorID);

                    String compositeID = String.Empty;
                    Int64  accountID   = 0;
                    if (pRMSupplierEntity != null && pRMSupplierEntity.SupplierID > 0)
                    {
                        Int64 referenceID, resourceCategoryID = 0;
                        referenceID = pRMSupplierEntity.SupplierID;

                        switch (pRMSupplierEntity.SupplierTypeID)
                        {
                        case MasterDataConstants.MDSupplierType.LOCAL:
                        case MasterDataConstants.MDSupplierType.IMPORTER:
                        case MasterDataConstants.MDSupplierType.LOCAL_AND_IMPORTER:
                            resourceCategoryID = MasterDataConstants.ACMDAccountResourceCategory.VENDOR;
                            break;

                        case MasterDataConstants.MDSupplierType.CONTRACTOR:
                            resourceCategoryID = MasterDataConstants.ACMDAccountResourceCategory.CONTRACTOR;
                            break;

                        case MasterDataConstants.MDSupplierType.CONSULTANT:
                            resourceCategoryID = MasterDataConstants.ACMDAccountResourceCategory.CONSULTANT;
                            break;
                        }



                        if (referenceID > 0 && resourceCategoryID > 0)
                        {
                            String fe1 = SqlExpressionBuilder.PrepareFilterExpression(ACAccountResourceAccountMapEntity.FLD_NAME_AccountResourceCategoryID, resourceCategoryID.ToString(), SQLMatchType.Equal);
                            String fe2 = SqlExpressionBuilder.PrepareFilterExpression(ACAccountResourceAccountMapEntity.FLD_NAME_ReferenceID, referenceID.ToString(), SQLMatchType.Equal);
                            String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                            IList <ACAccountResourceAccountMapEntity> lst = FCCACAccountResourceAccountMap.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                            if (lst != null && lst.Count > 0)
                            {
                                foreach (ACAccountResourceAccountMapEntity ent in lst)
                                {
                                    compositeID += ent.ReferenceID + ",";
                                    accountID    = ent.AccountID;
                                }

                                compositeID = compositeID.Substring(0, compositeID.Length - 1);
                            }
                        }
                    }

                    MiscUtil.PopulateACAccountByAccountGroupByReference(ddlACCAccountID, false, compositeID);

                    if (ddlACCAccountID != null && ddlACCAccountID.Items.Count > 0)
                    {
                        //ddlACCAccountID.SelectedValue = accountID.ToString();
                    }
                }
            }
            this.Panel1_ModalPopupExtender.Show();
        }
Exemple #17
0
        private Int64 UpdateTran(PRMSupplierEntity pRMSupplierEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMSupplier_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);

                db.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierEntity.SupplierID);
                db.AddInParameter(cmd, "@SupplierCode", DbType.String, pRMSupplierEntity.SupplierCode);
                db.AddInParameter(cmd, "@SupplierName", DbType.String, pRMSupplierEntity.SupplierName);
                db.AddInParameter(cmd, "@Relationship", DbType.String, pRMSupplierEntity.Relationship);
                db.AddInParameter(cmd, "@Phone", DbType.String, pRMSupplierEntity.Phone);
                db.AddInParameter(cmd, "@MobileNo", DbType.String, pRMSupplierEntity.MobileNo);
                db.AddInParameter(cmd, "@Fax", DbType.String, pRMSupplierEntity.Fax);
                db.AddInParameter(cmd, "@Email", DbType.String, pRMSupplierEntity.Email);
                db.AddInParameter(cmd, "@WebLink", DbType.String, pRMSupplierEntity.WebLink);
                db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, pRMSupplierEntity.CreateDate);
                db.AddInParameter(cmd, "@Remarks", DbType.String, pRMSupplierEntity.Remarks);
                db.AddInParameter(cmd, "@SupplierTypeID", DbType.Int64, pRMSupplierEntity.SupplierTypeID);
                db.AddInParameter(cmd, "@SupplierStatusID", DbType.Int64, pRMSupplierEntity.SupplierStatusID);
                db.AddInParameter(cmd, "@Reason", DbType.String, pRMSupplierEntity.Reason);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, pRMSupplierEntity.IsRemoved);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode > 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }