Exemplo n.º 1
0
        Int64 ICMBillDataAccess.Add(CMBillEntity cMBillEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        Int64 ICMBillDataAccess.Delete(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Delete(cMBillEntity, filterExpression, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = DeleteTran(cMBillEntity, filterExpression, option);
                    break;
                }

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        private Int64 Update(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMBill_SET";

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

                Database.AddInParameter(cmd, "@BillID", DbType.Int64, cMBillEntity.BillID);
                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMBillEntity.ProjectID);
                Database.AddInParameter(cmd, "@BillNo", DbType.String, cMBillEntity.BillNo);
                Database.AddInParameter(cmd, "@VendorCategory", DbType.Int64, cMBillEntity.VendorCategory);
                Database.AddInParameter(cmd, "@Vendor", DbType.Int64, cMBillEntity.Vendor);
                Database.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, cMBillEntity.WorkOrderID);
                Database.AddInParameter(cmd, "@DiscountAddition", DbType.Decimal, cMBillEntity.DiscountAddition);
                Database.AddInParameter(cmd, "@Vat", DbType.Decimal, cMBillEntity.Vat);
                Database.AddInParameter(cmd, "@Tax", DbType.Decimal, cMBillEntity.Tax);
                Database.AddInParameter(cmd, "@CarryingCharge", DbType.Decimal, cMBillEntity.CarryingCharge);
                Database.AddInParameter(cmd, "@Amount", DbType.Decimal, cMBillEntity.Amount);
                Database.AddInParameter(cmd, "@AdditionRemarks", DbType.String, cMBillEntity.AdditionRemarks);
                Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cMBillEntity.CreateDate);
                Database.AddInParameter(cmd, "@BillDate", DbType.DateTime, cMBillEntity.BillDate);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, cMBillEntity.Remarks);
                Database.AddInParameter(cmd, "@BillStatusID", DbType.Int64, cMBillEntity.BillStatusID);
                Database.AddInParameter(cmd, "@BillApprovalStatusID", DbType.Int64, cMBillEntity.BillApprovalStatusID);

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

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

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

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

            return(returnCode);
        }
Exemplo n.º 4
0
        protected void lvCMBill_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 BillID;

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

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

                    PrepareEditView();

                    if (CurrentCMBillEntity != null)
                    {
                        if (CurrentCMBillEntity.BillApprovalStatusID != MasterDataConstants.BillApprovalStatus.INITIATED)
                        {
                        }
                    }
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMBillEntity.FLD_NAME_BillID, BillID.ToString(), SQLMatchType.Equal);

                        CMBillEntity cMBillEntity = new CMBillEntity();


                        result = FCCCMBill.GetFacadeCreate().Delete(cMBillEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _BillID       = 0;
                            _CMBillEntity = new CMBillEntity();
                            PrepareInitialView();
                            BindCMBillList();

                            MiscUtil.ShowMessage(lblMessage, "Bill has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Bill.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private Int64 DeleteTran(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMBill_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);
        }
Exemplo n.º 6
0
        protected void lvCMBill_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 BillID;

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

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

                    String url = UrlHelper.BuildSecureUrl("~/CM/CMBill.aspx", string.Empty, UrlConstants.OVERVIEW_CM_BILL_ID, BillID.ToString()).ToString();
                    Response.Redirect(url);
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMBillEntity.FLD_NAME_BillID, BillID.ToString(), SQLMatchType.Equal);

                        CMBillEntity cMBillEntity = new CMBillEntity();


                        result = FCCCMBill.GetFacadeCreate().Delete(cMBillEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _BillID       = 0;
                            _CMBillEntity = new CMBillEntity();
                            BindCMBillList();

                            MiscUtil.ShowMessage(lblMessage, "C MBill has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete C MBill.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private Int64 Delete(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMBill_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("CMBillEntity already exists. Please specify another CMBillEntity.");
                    }

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

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

            return(returnCode);
        }
Exemplo n.º 8
0
 Int64 ICMBillFacade.Delete(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMBillDataAccess().Delete(cMBillEntity, filterExpression, option, reqTran));
 }
Exemplo n.º 9
0
 Int64 ICMBillFacade.Add(CMBillEntity cMBillEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMBillDataAccess().Add(cMBillEntity, option, reqTran));
 }
Exemplo n.º 10
0
        private Int64 UpdateTran(CMBillEntity cMBillEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMBill_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, "@BillID", DbType.Int64, cMBillEntity.BillID);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMBillEntity.ProjectID);
                db.AddInParameter(cmd, "@BillNo", DbType.String, cMBillEntity.BillNo);
                db.AddInParameter(cmd, "@VendorCategory", DbType.Int64, cMBillEntity.VendorCategory);
                db.AddInParameter(cmd, "@Vendor", DbType.Int64, cMBillEntity.Vendor);
                db.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, cMBillEntity.WorkOrderID);
                db.AddInParameter(cmd, "@DiscountAddition", DbType.Decimal, cMBillEntity.DiscountAddition);
                db.AddInParameter(cmd, "@Vat", DbType.Decimal, cMBillEntity.Vat);
                db.AddInParameter(cmd, "@Tax", DbType.Decimal, cMBillEntity.Tax);
                db.AddInParameter(cmd, "@CarryingCharge", DbType.Decimal, cMBillEntity.CarryingCharge);
                db.AddInParameter(cmd, "@Amount", DbType.Decimal, cMBillEntity.Amount);
                db.AddInParameter(cmd, "@AdditionRemarks", DbType.String, cMBillEntity.AdditionRemarks);
                db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, cMBillEntity.CreateDate);
                db.AddInParameter(cmd, "@BillDate", DbType.DateTime, cMBillEntity.BillDate);
                db.AddInParameter(cmd, "@Remarks", DbType.String, cMBillEntity.Remarks);
                db.AddInParameter(cmd, "@BillStatusID", DbType.Int64, cMBillEntity.BillStatusID);
                db.AddInParameter(cmd, "@BillApprovalStatusID", DbType.Int64, cMBillEntity.BillApprovalStatusID);

                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);
        }
Exemplo n.º 11
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _BillID       = 0;
     _CMBillEntity = new CMBillEntity();
     PrepareInitialView();
 }
Exemplo n.º 12
0
        private void SaveCMBillEntity()
        {
            if (ValidationInput())
            {
                if (IsValid)
                {
                    try
                    {
                        CMBillEntity cMBillEntity = BuildCMBillEntity();

                        Int64 result = -1;

                        if (cMBillEntity.IsNew)
                        {
                            result = FCCCMBill.GetFacadeCreate().Add(cMBillEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                        else
                        {
                            String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMBillEntity.FLD_NAME_BillID, cMBillEntity.BillID.ToString(), SQLMatchType.Equal);
                            result = FCCCMBill.GetFacadeCreate().Update(cMBillEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                        }

                        if (result > 0)
                        {
                            #region Update WO Final Bill Status

                            if (cMBillEntity.BillStatusID == MasterDataConstants.MDBillStatus.FINAL_BILL)
                            {
                                PRMWorkOrderEntity prmWorkOrderEntity = FCCPRMWorkOrder.GetFacadeCreate().GetByID(cMBillEntity.WorkOrderID);
                                prmWorkOrderEntity.IsFinalBilled = true;

                                String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMWorkOrderEntity.FLD_NAME_WorkOrderID, prmWorkOrderEntity.WorkOrderID.ToString(), SQLMatchType.Equal);

                                FCCPRMWorkOrder.GetFacadeCreate().Update(prmWorkOrderEntity, fe, DatabaseOperationType.Update, TransactionRequired.No);
                            }

                            #endregion

                            #region Bill Requisition Item Map

                            CMBillRequisitionItemMapEntity cMBillRequisitionItemMapEntity = new CMBillRequisitionItemMapEntity();


                            try
                            {
                                IList <ListViewDataItem> list = lvREQRequisitionItem.Items;

                                if (list != null && list.Count > 0)
                                {
                                    foreach (ListViewDataItem lvdi in list)
                                    {
                                        Decimal billPriceLV;
                                        TextBox txtBillPriceLV = (TextBox)lvdi.FindControl("txtBillPriceLV");
                                        Decimal.TryParse(txtBillPriceLV.Text.Trim(), out billPriceLV);

                                        if (billPriceLV > 0)
                                        {
                                            Label lblRequisitionIDLV     = (Label)lvdi.FindControl("lblRequisitionIDLV");
                                            Label lblRequisitionPriceLV  = (Label)lvdi.FindControl("lblRequisitionPriceLV");
                                            Label lblRequisitionItemIDLV = (Label)lvdi.FindControl("lblRequisitionItemIDLV");

                                            cMBillRequisitionItemMapEntity.BillID            = result;
                                            cMBillRequisitionItemMapEntity.RequisitionID     = Int64.Parse(lblRequisitionIDLV.Text);
                                            cMBillRequisitionItemMapEntity.RequisitionItemID = Int64.Parse(lblRequisitionItemIDLV.Text);
                                            cMBillRequisitionItemMapEntity.RequisitionPrice  = Decimal.Parse(lblRequisitionPriceLV.Text.Trim());

                                            if (billPriceLV > 0)
                                            {
                                                cMBillRequisitionItemMapEntity.BillPrice = Decimal.Parse(txtBillPriceLV.Text.Trim());
                                            }

                                            FCCCMBillRequisitionItemMap.GetFacadeCreate().Add(cMBillRequisitionItemMapEntity, DatabaseOperationType.Add, TransactionRequired.No);
                                            //else
                                            //{
                                            //    cMBillRequisitionItemMapEntity.BillPrice = null;
                                            //}
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }


                            #endregion

                            CMBillEntity _cMBillEntity = CurrentCMBillEntity;
                            _BillID       = 0;
                            _CMBillEntity = new CMBillEntity();
                            PrepareInitialView();
                            BindCMBillList();

                            if (cMBillEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Bill Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Bill Information has been updated successfully.", false);
                            }

                            String NavUrl = UrlHelper.BuildSecureUrl("~/CM/CMBillUploadInfo.aspx", string.Empty, UrlConstants.OVERVIEW_CM_BILL_ID, result.ToString()).ToString();
                            Response.Redirect(NavUrl);
                        }
                        else
                        {
                            if (cMBillEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Bill Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Bill Information.", false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private CMBillEntity BuildCMBillEntity()
        {
            CMBillEntity cMBillEntity = CurrentCMBillEntity;

            if (ddlProjectID.Items.Count > 0)
            {
                if (ddlProjectID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue);
                }
            }

            cMBillEntity.BillNo = txtBillNo.Text.Trim();

            if (ddlVendorCategoryID.Items.Count > 0)
            {
                if (ddlVendorCategoryID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.VendorCategory = Int64.Parse(ddlVendorCategoryID.SelectedValue);
                }
            }

            if (ddlVendorID.Items.Count > 0)
            {
                if (ddlVendorID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.Vendor = Int64.Parse(ddlVendorID.SelectedValue);
                }
            }

            if (ddlWorkOrderID.Items.Count > 0)
            {
                if (ddlWorkOrderID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.WorkOrderID = Int64.Parse(ddlWorkOrderID.SelectedValue);
                }
            }

            cMBillEntity.CreateDate = MiscUtil.ParseToDateTime(System.DateTime.Now.ToString(UIConstants.SHORT_DATE_FORMAT));

            if (txtBillDate.Text.Trim().IsNotNullOrEmpty())
            {
                cMBillEntity.BillDate = MiscUtil.ParseToDateTime(txtBillDate.Text);
            }


            if (!txtAmount.Text.Trim().IsNullOrEmpty())
            {
                cMBillEntity.Amount = Decimal.Parse(txtAmount.Text.Trim());
            }

            if (!txtAmount.Text.Trim().IsNullOrEmpty())
            {
                cMBillEntity.Amount = Decimal.Parse(txtAmount.Text.Trim());
            }

            if (ddlBillStatusID.Items.Count > 0)
            {
                if (ddlBillStatusID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.BillStatusID = Int64.Parse(ddlBillStatusID.SelectedValue);
                }
            }
            cMBillEntity.Remarks = txtRemarks.Text.Trim();

            if (ddlBillApprovalStatusID.Items.Count > 0)
            {
                if (ddlBillApprovalStatusID.SelectedValue == "0")
                {
                }
                else
                {
                    cMBillEntity.BillApprovalStatusID = Int64.Parse(ddlBillApprovalStatusID.SelectedValue);
                }
            }

            return(cMBillEntity);
        }
Exemplo n.º 14
0
        private void PrepareEditView()
        {
            if (CMBillID > 0)
            {
                _BillID = CMBillID;

                if (CurrentCMBillEntity != null)
                {
                    if (CurrentCMBillEntity.BillApprovalStatusID != MasterDataConstants.BillApprovalStatus.INITIATED)
                    {
                    }
                }
            }

            CMBillEntity cMBillEntity = CurrentCMBillEntity;


            if (!cMBillEntity.IsNew)
            {
                if (ddlProjectID.Items.Count > 0 && cMBillEntity.ProjectID != null)
                {
                    ddlProjectID.SelectedValue = cMBillEntity.ProjectID.ToString();
                }

                txtBillNo.Text = cMBillEntity.BillNo.ToString();

                if (ddlVendorCategoryID.Items.Count > 0 && cMBillEntity.VendorCategory != null)
                {
                    ddlVendorCategoryID.SelectedValue = cMBillEntity.VendorCategory.ToString();
                }

                BuildVendorByVendorCategory();

                if (ddlVendorID.Items.Count > 0 && cMBillEntity.Vendor != null)
                {
                    ddlVendorID.SelectedValue = cMBillEntity.Vendor.ToString();
                }

                BuildWOByVendor();

                if (ddlWorkOrderID.Items.Count > 0 && cMBillEntity.WorkOrderID != null)
                {
                    ddlWorkOrderID.SelectedValue = cMBillEntity.WorkOrderID.ToString();
                }
                txtBillDate.Text = cMBillEntity.BillDate.ToStringDefault();
                txtAmount.Text   = cMBillEntity.Amount.ToString();
                txtRemarks.Text  = cMBillEntity.Remarks.ToString();
                if (ddlBillStatusID.Items.Count > 0 && cMBillEntity.BillStatusID != null)
                {
                    ddlBillStatusID.SelectedValue = cMBillEntity.BillStatusID.ToString();
                }

                if (ddlBillApprovalStatusID.Items.Count > 0 && cMBillEntity.BillApprovalStatusID != null)
                {
                    ddlBillApprovalStatusID.SelectedValue = cMBillEntity.BillApprovalStatusID.ToString();
                }

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }