public IList <CRMAgreementSpecsEntity> GetPagedData(Int32 startRowIndex, Int32 pageSize, String sortExpression)
        {
            IList <CRMAgreementSpecsEntity> cRMAgreementSpecsEntityList = new List <CRMAgreementSpecsEntity>();

            try
            {
                if (pageSize == -1)
                {
                    pageSize = 1000000000;
                }

                if (String.IsNullOrEmpty(sortExpression))
                {
                    sortExpression = CRMAgreementSpecsEntity.FLD_NAME_AgreementSpecsID + " " + SQLConstants.SORT_ORDER_DESCENDING;
                }

                startRowIndex = Convert.ToInt32(startRowIndex / pageSize) + 1;

                cRMAgreementSpecsEntityList = FCCCRMAgreementSpecs.GetFacadeCreate().GetIL(startRowIndex, pageSize, sortExpression, null, DatabaseOperationType.LoadPagedWithSortExpression);

                if (cRMAgreementSpecsEntityList != null && cRMAgreementSpecsEntityList.Count > 0)
                {
                    totalRowCount = cRMAgreementSpecsEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(cRMAgreementSpecsEntityList ?? new List <CRMAgreementSpecsEntity>());
        }
        protected void lvCRMAgreementSpecs_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 AgreementSpecsID;

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

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

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMAgreementSpecsEntity.FLD_NAME_AgreementSpecsID, AgreementSpecsID.ToString(), SQLMatchType.Equal);

                        CRMAgreementSpecsEntity cRMAgreementSpecsEntity = new CRMAgreementSpecsEntity();


                        result = FCCCRMAgreementSpecs.GetFacadeCreate().Delete(cRMAgreementSpecsEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _AgreementSpecsID        = 0;
                            _CRMAgreementSpecsEntity = new CRMAgreementSpecsEntity();
                            PrepareInitialView();
                            BindCRMAgreementSpecsList();

                            MiscUtil.ShowMessage(lblMessage, "C RMAgreement Specs has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete C RMAgreement Specs.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        public IList <CRMAgreementSpecsEntity> GetData()
        {
            IList <CRMAgreementSpecsEntity> cRMAgreementSpecsEntityList = new List <CRMAgreementSpecsEntity>();

            try
            {
                cRMAgreementSpecsEntityList = FCCCRMAgreementSpecs.GetFacadeCreate().GetIL(null, null, null, null, DatabaseOperationType.Load);

                if (cRMAgreementSpecsEntityList != null && cRMAgreementSpecsEntityList.Count > 0)
                {
                    totalRowCount = cRMAgreementSpecsEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(cRMAgreementSpecsEntityList ?? new List <CRMAgreementSpecsEntity>());
        }
        private void SaveCRMAgreementSpecsEntity()
        {
            if (IsValid)
            {
                try
                {
                    CRMAgreementSpecsEntity cRMAgreementSpecsEntity = BuildCRMAgreementSpecsEntity();

                    Int64 result = -1;

                    if (cRMAgreementSpecsEntity.IsNew)
                    {
                        result = FCCCRMAgreementSpecs.GetFacadeCreate().Add(cRMAgreementSpecsEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMAgreementSpecsEntity.FLD_NAME_AgreementSpecsID, cRMAgreementSpecsEntity.AgreementSpecsID.ToString(), SQLMatchType.Equal);
                        result = FCCCRMAgreementSpecs.GetFacadeCreate().Update(cRMAgreementSpecsEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        if (cRMAgreementSpecsEntity.IsNew)
                        {
                            for (Int32 i = 1; i <= 5; i++)
                            {
                                CRMAgreementVariableMapEntity ent = new CRMAgreementVariableMapEntity();
                                switch (i)
                                {
                                //case 1:
                                //    ent.Name = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType+"_"+cRMAgreementSpecsEntity.Item +"_IName"+ result.ToString() + "%&gt;";
                                //    ent.Value = cRMAgreementSpecsEntity.Item;
                                //    break;
                                //case 2:
                                //    ent.Name = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_" + ddlBrandID.SelectedItem + "_IBrand_" + result.ToString() + "%&gt;";
                                //    ent.Value = ddlBrandID.SelectedItem.ToString();
                                //    break;
                                //case 3:
                                //    ent.Name = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_" + cRMAgreementSpecsEntity.Item+"_IQty_"+ result.ToString()+ "%&gt;";
                                //    ent.Value = cRMAgreementSpecsEntity.BayQty.ToString();
                                //    break;
                                //case 4:
                                //    ent.Name = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_" + cRMAgreementSpecsEntity.Item+"_IPrice_"+ result.ToString()+"%&gt;";
                                //    ent.Value = cRMAgreementSpecsEntity.BayPrice.ToString();
                                //    break;
                                //case 5:
                                //    ent.Name = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_" + cRMAgreementSpecsEntity.Field1+ "_IUnit_"+ result.ToString() + "%&gt;";
                                //    ent.Value = cRMAgreementSpecsEntity.Field1.ToString();
                                //    break;

                                case 1:
                                    ent.Name  = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_IName" + result.ToString() + "%&gt;";
                                    ent.Value = cRMAgreementSpecsEntity.Item;
                                    break;

                                case 2:
                                    ent.Name  = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_IBrand_" + result.ToString() + "%&gt;";
                                    ent.Value = ddlBrandID.SelectedItem.ToString();
                                    break;

                                case 3:
                                    ent.Name  = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_IQty_" + result.ToString() + "%&gt;";
                                    ent.Value = cRMAgreementSpecsEntity.BayQty.ToString();
                                    break;

                                case 4:
                                    ent.Name  = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_IPrice_" + result.ToString() + "%&gt;";
                                    ent.Value = cRMAgreementSpecsEntity.BayPrice.ToString();
                                    break;

                                case 5:
                                    ent.Name  = "&lt;%$$" + cRMAgreementSpecsEntity.AgreementSpecsType + "_IUnit_" + result.ToString() + "%&gt;";
                                    ent.Value = cRMAgreementSpecsEntity.Field1.ToString();
                                    break;
                                }

                                ent.CreateDate          = System.DateTime.Now;
                                ent.CreatedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember);
                                ent.IP          = MiscUtil.GetLocalIP();
                                ent.Remarks     = "Auto Generated";
                                ent.AgreementID = OverviewAgreementID;

                                FCCCRMAgreementVariableMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
                            }
                        }
                        _AgreementSpecsID        = 0;
                        _CRMAgreementSpecsEntity = new CRMAgreementSpecsEntity();
                        PrepareInitialView();
                        BindCRMAgreementSpecsList();

                        if (cRMAgreementSpecsEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Agreement Specs Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Agreement Specs Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cRMAgreementSpecsEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Agreement Specs Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Agreement Specs Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }