Exemple #1
0
        public VOVendor GetCriteria()
        {
            VOVendor criteria = new VOVendor();

            criteria.VendorBranch   = ctlBranch.Text.Trim();
            criteria.VendorTaxCode  = ctlTaxId.Text.Trim();
            criteria.VendorCode     = ctlVendorCode.Text.Trim();
            criteria.VendorName     = ctlVendorName.Text.Trim();
            criteria.ExcludeOneTime = excludeOneTime;
            return(criteria);
        }
Exemple #2
0
        protected void ctlSubmit_Click(object sender, EventArgs e)
        {
            IList <VOVendor> list = new List <VOVendor>();

            foreach (GridViewRow row in ctlVendorGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    //long id = UIHelper.ParseShort(ctlVendorGrid.DataKeys[row.RowIndex].Values["VendorID"].ToString());
                    //DbVendor dbVendor = ScgDbQueryProvider.DbVendorQuery.FindByIdentity(id);
                    //list.Add(dbVendor);
                    int   rowIndex   = row.RowIndex;
                    Label vendorCode = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridVendorCode") as Label;
                    Label vendorName = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridVendorName") as Label;
                    Label taxCode    = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridTaxID") as Label;
                    Label street     = ctlVendorGrid.Rows[rowIndex].FindControl("ctlStreet") as Label;
                    Label country    = ctlVendorGrid.Rows[rowIndex].FindControl("ctlCountry") as Label;
                    Label city       = ctlVendorGrid.Rows[rowIndex].FindControl("ctlCity") as Label;
                    Label postalCode = ctlVendorGrid.Rows[rowIndex].FindControl("ctlPostalCode") as Label;
                    Label branch     = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridBranch") as Label;
                    long? vendorID   = null;
                    if (ctlVendorGrid.DataKeys[rowIndex].Value != null)
                    {
                        vendorID = UIHelper.ParseLong(ctlVendorGrid.DataKeys[rowIndex].Value.ToString());
                    }

                    VOVendor vendor = new VOVendor();
                    vendor.VendorID      = vendorID;
                    vendor.VendorCode    = vendorCode.Text;
                    vendor.VendorName    = vendorName.Text;
                    vendor.VendorTaxCode = taxCode.Text;
                    vendor.Street        = street.Text;
                    vendor.Country       = country.Text;
                    vendor.City          = city.Text;
                    vendor.PostalCode    = postalCode.Text;
                    vendor.VendorBranch  = branch.Text;
                    list.Add(vendor);
                }
            }

            JavaScriptSerializer serialize = new JavaScriptSerializer();
            string vendorInfo = serialize.Serialize(list);

            CallOnObjectLookUpReturn(vendorInfo);
        }
        protected void ctlVendorChange_OnVendorChanged(object sender, EventArgs e)
        {
            VOVendor vendor = new VOVendor();

            if (!string.IsNullOrEmpty(ctlVendorID.Text))
            {
                vendor.VendorID = UIHelper.ParseLong(ctlVendorID.Text);
            }
            vendor.VendorName    = txtVendorName.Text;
            vendor.VendorCode    = ctlVendorCode.Text;
            vendor.Street        = ctlStreet.Text;
            vendor.City          = ctlCity.Text;
            vendor.Country       = ctlCountry.Text;
            vendor.PostalCode    = ctlPostal.Text;
            vendor.VendorTaxCode = txtTaxNo.Text;

            if (ChangedVendor != null)
            {
                ChangedVendor(this, vendor);
            }
        }
Exemple #4
0
        protected void ctlVendorGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (!isMultiple)
            {
                if (e.CommandName.Equals("Select"))
                {
                    int   rowIndex   = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    Label vendorCode = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridVendorCode") as Label;
                    Label vendorName = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridVendorName") as Label;
                    Label taxCode    = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridTaxID") as Label;
                    Label street     = ctlVendorGrid.Rows[rowIndex].FindControl("ctlStreet") as Label;
                    Label country    = ctlVendorGrid.Rows[rowIndex].FindControl("ctlCountry") as Label;
                    Label city       = ctlVendorGrid.Rows[rowIndex].FindControl("ctlCity") as Label;
                    Label postalCode = ctlVendorGrid.Rows[rowIndex].FindControl("ctlPostalCode") as Label;
                    Label branch     = ctlVendorGrid.Rows[rowIndex].FindControl("ctlGridBranch") as Label;


                    long?vendorID = null;
                    if (ctlVendorGrid.DataKeys[rowIndex].Value != null)
                    {
                        vendorID = UIHelper.ParseLong(ctlVendorGrid.DataKeys[rowIndex].Value.ToString());
                    }

                    VOVendor vendor = new VOVendor();
                    vendor.VendorID      = vendorID;
                    vendor.VendorCode    = vendorCode.Text;
                    vendor.VendorName    = vendorName.Text;
                    vendor.VendorTaxCode = taxCode.Text;
                    vendor.Street        = street.Text;
                    vendor.Country       = country.Text;
                    vendor.City          = city.Text;
                    vendor.PostalCode    = postalCode.Text;
                    vendor.VendorBranch  = branch.Text;
                    JavaScriptSerializer serialize = new JavaScriptSerializer();
                    string vendorInfo = serialize.Serialize(vendor);
                    CallOnObjectLookUpReturn(vendorInfo);
                }
            }
        }
        protected void ctlReturnAction_ValueChanged(object sender, EventArgs e)
        {
            VOVendor vendor = new VOVendor();

            if (!string.IsNullOrEmpty(ctlVendorID.Text))
            {
                vendor.VendorID = UIHelper.ParseLong(ctlVendorID.Text);
            }
            vendor.VendorName    = txtVendorName.Text;
            vendor.VendorCode    = ctlVendorCode.Text;
            vendor.Street        = ctlStreet.Text;
            vendor.City          = ctlCity.Text;
            vendor.Country       = ctlCountry.Text;
            vendor.PostalCode    = ctlPostal.Text;
            vendor.VendorTaxCode = txtTaxNo.Text;

            if (ChangedVendor != null)
            {
                ChangedVendor(this, vendor);
            }
            //NotifyPopupResult(this, ctlReturnAction.Value, ctlReturnValue.Value);
            ctlReturnAction.Value = "";
        }
Exemple #6
0
        protected void ctlVendorLookupPopupCaller_NotifyPopupResult(object sender, string action, string value)
        {
            if (action != "ok")
            {
                return;
            }
            JavaScriptSerializer serialize = new JavaScriptSerializer();
            object returnValue             = new object();

            if (!isMultiple)
            {
                VOVendor vendor = serialize.Deserialize <VOVendor>(value);
                returnValue = vendor;
                //NotifyPopUpReturn(new PopUpReturnArgs(PopUpReturnType.OK, vendor));
            }
            else
            {
                IList <VOVendor> list = serialize.Deserialize <IList <VOVendor> >(value);
                returnValue = list;
                //CallOnObjectLookUpReturn(list);
            }
            CallOnObjectLookUpReturn(returnValue);
        }
 public int CountVendorByVendorCriteria(VOVendor criteria)
 {
     return(NHibernateQueryHelper.CountByCriteria(ScgDbQueryProvider.DbVendorQuery, "FindVendorByVendorCriteria", new object[] { criteria, true, string.Empty }));
 }
 public IList <VOVendor> GetVendorListByVendorCriteria(VOVendor criteria, int firstResult, int maxResult, string sortExpression)
 {
     return(NHibernateQueryHelper.FindPagingByCriteria <VOVendor>(ScgDbQueryProvider.DbVendorQuery, "FindVendorByVendorCriteria", new object[] { criteria, false, sortExpression }, firstResult, maxResult, sortExpression));
 }
        public ISQLQuery FindVendorByVendorCriteria(VOVendor criteria, bool isCount, string sortExpession)
        {
            StringBuilder sqlBuilder = new StringBuilder();

            if (isCount)
            {
                sqlBuilder.Append(" select count(*) as VendorCount ");
            }
            else
            {
                sqlBuilder.Append(" select  VendorID, VendorCode, VendorBranch, Street, City, Country, PostalCode, VendorName, VendorTaxCode   ");
            }
            sqlBuilder.Append(" from (");
            sqlBuilder.Append(" select VendorID, VendorCode, TaxNo4 as VendorBranch, Street, City, Country, PostalCode, ");
            sqlBuilder.Append(" isnull(VendorTitle,'') +' '+ isnull(VendorName1,'') +' '+ isnull(VendorName2,'') as VendorName , isnull(TaxNo3,'') as VendorTaxCode");
            sqlBuilder.Append(" from DbVendor with (nolock) where Active = 1" + (string.IsNullOrEmpty(criteria.VendorTaxCode) ? string.Empty : " and TaxNo3 like :TaxCode"));
            sqlBuilder.Append(" union select null as VendorID, VendorCode, VendorBranch,Street, City, Country, PostalCode, VendorName, VendorTaxCode ");
            sqlBuilder.Append(" from DbOneTimeVendor with (nolock) where 1=1 " + (string.IsNullOrEmpty(criteria.VendorTaxCode) ? string.Empty : " and VendorTaxCode like :TaxCode "));
            sqlBuilder.Append(" union select null as VendorID, t.VendorCode, t.VendorBranch,t.Street, t.City, t.Country, t.PostalCode, t.VendorName, t.VendorTaxCode ");
            sqlBuilder.Append(" from FnExpenseInvoice t with (nolock) where t.Active = 1 and (convert(varchar,CreDate,103)= convert(varchar,:CreDate,103)) ");
            sqlBuilder.Append(" and NULLIF (t.VendorCode, '') <> '' and NULLIF (t.VendorName, '') <> '' ");
            sqlBuilder.Append(" and NULLIF (t.Street, '') <> '' and NULLIF (t.Country, '') <> '' and NULLIF (t.VendorTaxCode, '') <> '' " + (string.IsNullOrEmpty(criteria.VendorTaxCode) ? string.Empty : " and t.VendorTaxCode like :TaxCode "));
            sqlBuilder.Append(" and t.VendorID = null ");
            sqlBuilder.Append(" and not exists(SELECT 'X' FROM DbOneTimeVendor o WHERE o.VendorTaxCode = t.VendorTaxCode AND o.VendorBranch = t.VendorBranch) ");
            sqlBuilder.Append(" )t1 ");
            QueryParameterBuilder parameterBuilder = new QueryParameterBuilder();

            parameterBuilder.AddParameterData("CreDate", typeof(DateTime), DateTime.Today);

            StringBuilder whereClause = new StringBuilder();

            if (!string.IsNullOrEmpty(criteria.VendorCode))
            {
                whereClause.Append(" and VendorCode like :VendorCode ");
                parameterBuilder.AddParameterData("VendorCode", typeof(string), String.Format("%{0}%", criteria.VendorCode));
            }
            if (!string.IsNullOrEmpty(criteria.VendorName))
            {
                whereClause.Append(" and VendorName like :VendorName ");
                parameterBuilder.AddParameterData("VendorName", typeof(string), String.Format("%{0}%", criteria.VendorName));
            }
            if (!string.IsNullOrEmpty(criteria.VendorTaxCode))
            {
                //whereClause.Append(" and VendorTaxCode like :TaxCode ");
                parameterBuilder.AddParameterData("TaxCode", typeof(string), String.Format("%{0}%", criteria.VendorTaxCode));
            }
            if (!string.IsNullOrEmpty(criteria.VendorBranch))
            {
                whereClause.Append(" and VendorBranch like :VendorBranch ");
                parameterBuilder.AddParameterData("VendorBranch", typeof(string), String.Format("%{0}%", criteria.VendorBranch));
            }
            if (criteria.ExcludeOneTime)
            {
                whereClause.Append(" and VendorID is not null ");
            }

            if (!string.IsNullOrEmpty(whereClause.ToString()))
            {
                sqlBuilder.Append(String.Format(" where 1=1 {0}", whereClause.ToString()));
            }

            if (!isCount)
            {
                if (!string.IsNullOrEmpty(sortExpession))
                {
                    sqlBuilder.Append(String.Format(" order by {0} ", sortExpession));
                }
                else
                {
                    sqlBuilder.Append(" order by VendorID, VendorCode, VendorName, VendorTaxCode");
                }
            }
            ISQLQuery query = GetCurrentSession().CreateSQLQuery(sqlBuilder.ToString());

            parameterBuilder.FillParameters(query);

            if (!isCount)
            {
                query.AddScalar("VendorID", NHibernateUtil.Int64)
                .AddScalar("VendorCode", NHibernateUtil.String)
                .AddScalar("VendorBranch", NHibernateUtil.String)
                .AddScalar("Street", NHibernateUtil.String)
                .AddScalar("City", NHibernateUtil.String)
                .AddScalar("Country", NHibernateUtil.String)
                .AddScalar("PostalCode", NHibernateUtil.String)
                .AddScalar("VendorName", NHibernateUtil.String)
                .AddScalar("VendorTaxCode", NHibernateUtil.String);

                query.SetResultTransformer(Transformers.AliasToBean(typeof(VOVendor)));
            }
            else
            {
                query.AddScalar("VendorCount", NHibernateUtil.Int32);
                query.UniqueResult();
            }
            return(query);
        }