protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!string.IsNullOrEmpty(Onblur))
                {
                    txtTaxNo.Attributes.Remove("onblur");
                    txtTaxNo.Attributes.Add("onblur", string.Format("{0};", Onblur));
                }
            }
            //ctlVendorAutoComplete.BehaviorID = String.Format("VendorAutoCompleteEx{0}", txtTaxNo.ClientID);
            SetAutoCompleteEvent();

            long vendorID = UIHelper.ParseLong(VendorId.ToString());

            DbVendor parameter = new DbVendor();
            //parameter.VendorID      = vendorID;
            //parameter.VendorCode    = VendorCode;
            //parameter.VendorName1   = VendorName;
            //parameter.Street        = Street;
            //parameter.City          = City;
            //parameter.Country       = Country;
            //parameter.PostalCode    = PostalCode;

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            //ctlVendorAutoComplete.ContextKey = serializer.Serialize(parameter);
            //ctlVendorAutoComplete.UseContextKey = true;
        }
Exemple #2
0
        protected void ctlFormViewVendor_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            long     VendorID = UIHelper.ParseLong(ctlFormViewVendor.DataKey.Value.ToString());
            DbVendor Vendor   = DbVendorService.FindByIdentity(VendorID);

            TextBox  txtVendorCode  = ctlFormViewVendor.FindControl("ctlTxtVendorCode") as TextBox;
            TextBox  txtVendorTitle = ctlFormViewVendor.FindControl("ctlTxtVendorTitle") as TextBox;
            TextBox  txtVendorName1 = ctlFormViewVendor.FindControl("ctlTxtVendorName1") as TextBox;
            TextBox  txtVendorName2 = ctlFormViewVendor.FindControl("ctlTxtVendorName2") as TextBox;
            TextBox  txtStreet      = ctlFormViewVendor.FindControl("ctlTxtStreet") as TextBox;
            TextBox  txtCity        = ctlFormViewVendor.FindControl("ctlTxtCity") as TextBox;
            TextBox  txtDistrict    = ctlFormViewVendor.FindControl("ctlTxtDistrict") as TextBox;
            TextBox  txtCountry     = ctlFormViewVendor.FindControl("ctlTxtCountry") as TextBox;
            TextBox  txtPostalCode  = ctlFormViewVendor.FindControl("ctlTxtPostalCode") as TextBox;
            TextBox  txtTaxNo1      = ctlFormViewVendor.FindControl("ctlTxtTaxNo1") as TextBox;
            TextBox  txtTaxNo2      = ctlFormViewVendor.FindControl("ctlTxtTaxNo2") as TextBox;
            TextBox  txtTaxNo3      = ctlFormViewVendor.FindControl("ctlTxtTaxNo3") as TextBox;
            TextBox  txtTaxNo4      = ctlFormViewVendor.FindControl("ctlTxtTaxNo4") as TextBox;
            CheckBox chkBlockDelete = ctlFormViewVendor.FindControl("chkBlockDelete") as CheckBox;
            CheckBox chkBlockPost   = ctlFormViewVendor.FindControl("chkBlockPost") as CheckBox;
            CheckBox chkActive      = ctlFormViewVendor.FindControl("chkActive") as CheckBox;

            Vendor.VendorCode  = txtVendorCode.Text;
            Vendor.VendorTitle = txtVendorTitle.Text;
            Vendor.VendorName1 = txtVendorName1.Text;
            Vendor.VendorName2 = txtVendorName2.Text;
            Vendor.Street      = txtStreet.Text;
            Vendor.City        = txtCity.Text;
            Vendor.District    = txtDistrict.Text;
            Vendor.Country     = txtCountry.Text;
            Vendor.PostalCode  = txtPostalCode.Text;
            Vendor.TaxNo1      = txtTaxNo1.Text;
            Vendor.TaxNo2      = txtTaxNo2.Text;
            Vendor.TaxNo3      = txtTaxNo3.Text;
            Vendor.TaxNo4      = txtTaxNo4.Text;
            Vendor.BlockDelete = chkBlockDelete.Checked;
            Vendor.BlockPost   = chkBlockPost.Checked;
            Vendor.Active      = chkActive.Checked;

            Vendor.UpdPgm  = ProgramCode;
            Vendor.UpdDate = DateTime.Now.Date;
            Vendor.UpdBy   = UserAccount.UserID;

            try
            {
                CheckDataValueUpdate(Vendor);
                DbVendorService.SaveOrUpdate(Vendor);

                e.Cancel = true;
                ctlGridVendor.DataCountAndBind();
                ctlModalPopupVendor.Hide();
                updPanelGridView.Update();

                //ctlMessage.Message = GetMessage("SaveSuccessFully");
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
Exemple #3
0
        protected void Vendor1_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e)
        {
            IList <DbVendor> vendor   = (IList <DbVendor>)e.ObjectReturn;
            DbVendor         dbVendor = vendor.First <DbVendor>();

            //ctlTaxNo.TaxNo = dbVendor.TaxNo1;
            ctlVendorCode.Text = dbVendor.VendorCode;
            if (dbVendor.TaxNo1 != null && dbVendor.TaxNo2 == null)
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo1;
                ctlVendorName.Text = dbVendor.VendorName1;
            }
            else if (dbVendor.TaxNo2 != null && dbVendor.TaxNo1 == null)
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo2;
                ctlVendorName.Text = dbVendor.VendorName2;
            }
            else
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo2;
                ctlVendorName.Text = dbVendor.VendorName2;
            }
            ctlStreet.Text     = dbVendor.Street;
            ctlCity.Text       = dbVendor.City;
            ctlCountry.Text    = dbVendor.Country;
            ctlPostalCode.Text = dbVendor.PostalCode;
            CallOnObjectLookUpReturn(dbVendor);
            ctlUpdatePanelVendor.Update();
        }
Exemple #4
0
        protected void ctlTaxNo_NotifyPopupResult(object sender, string action, string result)
        {
            //if (action != "ok") //return;
            IList <DbVendor> iListDbVendor = ScgDbQueryProvider.DbVendorQuery.FindByDbVendor(UIHelper.ParseLong(result));
            DbVendor         dbVendor      = iListDbVendor.First <DbVendor>();

            ctlVendorCode.Text = dbVendor.VendorCode;
            if (dbVendor.TaxNo1 != null && dbVendor.TaxNo2 == null)
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo1;
                ctlVendorName.Text = dbVendor.VendorName1;
            }
            else if (dbVendor.TaxNo2 != null && dbVendor.TaxNo1 == null)
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo2;
                ctlVendorName.Text = dbVendor.VendorName2;
            }
            else
            {
                ctlTaxNo.TaxNo     = dbVendor.TaxNo2;
                ctlVendorName.Text = dbVendor.VendorName2;
            }

            ctlStreet.Text     = dbVendor.Street;
            ctlCity.Text       = dbVendor.City;
            ctlCountry.Text    = dbVendor.Country;
            ctlPostalCode.Text = dbVendor.PostalCode;
            CallOnObjectLookUpReturn(dbVendor);
        }
Exemple #5
0
        private void CheckDataValueUpdate(DbVendor Vendor)
        {
            Literal ctlLblVenderCodeInGrid = ctlGridVendor.Rows[ctlGridVendor.EditIndex].FindControl("ctlLblVendorCode") as Literal;
            TextBox txtVendorCode          = ctlFormViewVendor.FindControl("ctlTxtVendorCode") as TextBox;

            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(Vendor.VendorCode))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("VendorCode"));
            }
            if (string.IsNullOrEmpty(Vendor.VendorName1))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("VendorName1"));
            }
            if (string.IsNullOrEmpty(Vendor.Street))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("Street"));
            }
            if (string.IsNullOrEmpty(Vendor.City))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("City"));
            }
            if (string.IsNullOrEmpty(Vendor.Country))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("Country"));
            }
            if (string.IsNullOrEmpty(Vendor.PostalCode))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("PostalCode"));
            }
            if (
                (ctlLblVenderCodeInGrid.Text != txtVendorCode.Text) &&
                (ScgDbQueryProvider.DbVendorQuery.isDuplicationVendorCode(Vendor.VendorCode))
                )
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("DuplicationVendorCode"));
            }

            //if (!string.IsNullOrEmpty(Vendor.TaxNo1) && !string.IsNullOrEmpty(Vendor.TaxNo2))
            //    errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNoHaveOneValueOnly"));
            //else if (string.IsNullOrEmpty(Vendor.TaxNo1) && string.IsNullOrEmpty(Vendor.TaxNo2))
            //    errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNoIsEmpty"));

            if (string.IsNullOrEmpty(Vendor.TaxNo3))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNo3IsEmpty"));
            }

            if (string.IsNullOrEmpty(Vendor.TaxNo4))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNo4IsEmpty"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
Exemple #6
0
        private void CheckDataValueInsert(DbVendor Vendor)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(Vendor.VendorCode))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("VendorCode"));
            }
            if (string.IsNullOrEmpty(Vendor.VendorName1))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("VendorName1"));
            }
            if (string.IsNullOrEmpty(Vendor.Street))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("Street"));
            }
            if (string.IsNullOrEmpty(Vendor.City))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("City"));
            }
            if (string.IsNullOrEmpty(Vendor.Country))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("Country"));
            }
            if (string.IsNullOrEmpty(Vendor.PostalCode))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("PostalCode"));
            }
            if (ScgDbQueryProvider.DbVendorQuery.isDuplicationVendorCode(Vendor.VendorCode))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("DuplicationVendorCode"));
            }

            //if (!string.IsNullOrEmpty(Vendor.TaxNo1) && !string.IsNullOrEmpty(Vendor.TaxNo2))
            //    errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNoHaveOneValueOnly"));
            //else if (string.IsNullOrEmpty(Vendor.TaxNo1) && string.IsNullOrEmpty(Vendor.TaxNo2))
            //    errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNoIsEmpty"));

            if (string.IsNullOrEmpty(Vendor.TaxNo3))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNo3IsEmpty"));
            }

            if (string.IsNullOrEmpty(Vendor.TaxNo4))
            {
                errors.AddError("Vendor.Error", new Spring.Validation.ErrorMessage("TaxNo4IsEmpty"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
Exemple #7
0
        private IDbCommand GetCommand(DbVendor vendor, string sql)
        {
            switch (vendor)
            {
            case DbVendor.Oracle:
                return(new OracleCommand(sql, this.connection as OracleConnection));

            case DbVendor.MySQL:
                throw new Exception("MySQL not implemented!");

            case DbVendor.Firebird:
                throw new Exception("Firebird not implemented!");

            case DbVendor.MSSQL:
                throw new Exception("MSSQL not implemented!");

            default:
                throw new Exception("Database vendor unknown!");
            }
        }
Exemple #8
0
        private IDataAdapter GetDataAdapter(DbVendor vendor, string sql)
        {
            switch (vendor)
            {
            case DbVendor.Oracle:
                OracleCommand ocommand = GetCommand(vendor, sql) as OracleCommand;
                return(new OracleDataAdapter(ocommand));

            case DbVendor.MySQL:
                throw new Exception("MySQL not implemented!");

            case DbVendor.Firebird:
                throw new Exception("Firebird not implemented!");

            case DbVendor.MSSQL:
                throw new Exception("MSSQL not implemented!");

            default:
                throw new Exception("Database vendor unknown!");
            }
        }
        public string[] GetVendorList(string prefixText, int count, string contextKey)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            // AutoCompleteParameter is a ValueObject DTO that used in AutoComplete only
            DbVendor parameter = serializer.Deserialize <DbVendor>(contextKey);

            // Retreive Query Object from Spring
            IDbVendorQuery dbVendorQuery = (IDbVendorQuery)ContextRegistry.GetContext().GetObject("DbVendorQuery");

            IList <VOVendor> vendorList = dbVendorQuery.FindByVendorAutoComplete(prefixText);

            List <string> items = new List <string>(vendorList.Count);

            foreach (VOVendor vendor in vendorList)
            {
                string item = AutoCompleteExtender.CreateAutoCompleteItem(String.Format("[{0}]{1}", vendor.VendorTaxCode, vendor.VendorName), serializer.Serialize(vendor));
                items.Add(item);
            }

            return(items.ToArray());
        }
Exemple #10
0
        protected void ctlGridVendor_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "VendorEdit")
            {
                int  rowIndex   = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                long VendorCode = UIHelper.ParseLong(ctlGridVendor.DataKeys[rowIndex].Value.ToString());

                ctlGridVendor.EditIndex = rowIndex;
                IList <DbVendor> VendorList = new List <DbVendor>();
                DbVendor         Vendor     = DbVendorService.FindByIdentity(VendorCode);

                VendorList.Add(Vendor);

                ctlFormViewVendor.DataSource = VendorList;
                ctlFormViewVendor.PageIndex  = 0;

                ctlFormViewVendor.ChangeMode(FormViewMode.Edit);
                ctlFormViewVendor.DataBind();

                updPanelFormView.Update();
                ctlModalPopupVendor.Show();
            }
            else if (e.CommandName == "VendorDelete")
            {
                int  rowIndex   = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                long VendorCode = UIHelper.ParseLong(ctlGridVendor.DataKeys[rowIndex].Value.ToString());

                DbVendor Vendor = DbVendorService.FindByIdentity(VendorCode);

                DbVendorService.Delete(Vendor);
                ctlGridVendor.DataCountAndBind();
                updPanelGridView.Update();

                //ctlMessage.Message = GetMessage("DeleteSuccessFully");
            }
        }
Exemple #11
0
        public DbUtil(DbVendor vendor, string connStr, bool openTx)
        {
            this.vendor = vendor;
            switch (vendor)
            {
            case DbVendor.Oracle:
                this.connection = new OracleConnection(connStr);
                break;

            case DbVendor.MySQL:
                throw new Exception("MySQL not implemented!");

            case DbVendor.Firebird:
                throw new Exception("Firebird not implemented!");

            case DbVendor.MSSQL:
                throw new Exception("MSSQL not implemented!");

            default:
                throw new Exception("Database vendor unknown!");
            }
            this.connection.Open();
            this.tranx = openTx ? this.connection.BeginTransaction() : null;
        }
Exemple #12
0
        /// <summary>
        /// 得到UserConnectString
        /// </summary>
        /// <param name="ucode">账套代码</param>
        public string GetUserConnectString(string ucode)
        {
            if (string.IsNullOrEmpty(this.ConnectString))
            {
                GetW3ConnectString();
            }
            NGDbTrans db = NGDbFactory.Instance.GetDbTrans(this.ConnectString);
            //数据库连接类型
            DBCType dbcType = db.DBCType;
            //数据库类型
            DbVendor dbVendor = db.Vendor;
            string   sServerName = "", sDbName = "", sDbLogID = "", sDbLogPass = "", sUserConnectString = "";

            sServerName = NG.NGConvert.GetKeyValue(this.ConnectString, "Data Source");
            if (sServerName == null || sServerName == "")
            {
                sServerName = NG.NGConvert.GetKeyValue(this.ConnectString, "Server");
            }
            sDbName  = this.GetDbName(ucode);
            sDbLogID = NG.NGConvert.GetKeyValue(this.ConnectString, "UID");
            if (sDbLogID == null || sDbLogID == "")
            {
                sDbLogID = NG.NGConvert.GetKeyValue(this.ConnectString, "User ID");
            }
            sDbLogPass = NG.NGConvert.GetKeyValue(this.ConnectString, "PWD");
            if (sDbLogPass == null || sDbLogPass == "")
            {
                sDbLogPass = NG.NGConvert.GetKeyValue(this.ConnectString, "Password");
                if (sDbLogPass.Length == 128)
                {
                    sDbLogPass = NG.NGEncode.DecodePassword(sDbLogPass, 128);
                }
            }

            if (dbcType == DBCType.SqlClient) //SqlClient
            {
                sUserConnectString = NGDbFactory.Instance.ComboSqlConnString(sServerName, sDbName, sDbLogID, sDbLogPass, "");
            }
            else if (dbcType == DBCType.OleDb)      //OleDb
            {
                if (dbVendor == DbVendor.SQLServer) //SQLServer
                {
                    sUserConnectString = NGDbFactory.Instance.ComboOleDbConnString(DbVendor.SQLServer, sServerName, sDbName, sDbLogID, sDbLogPass, "");
                }
                else if (dbVendor == DbVendor.Oracle) //Oracle
                {
                    sDbLogPass         = this.GetOracleUserPassWord(ucode);
                    sUserConnectString = NGDbFactory.Instance.ComboOleDbConnString(DbVendor.Oracle, sServerName, "", sDbName, sDbLogPass, "");
                }
                string sProvider = NG.NGConvert.GetKeyValue(this.ConnectString, "Provider");
                if (sProvider.ToUpper() == "MSDATASHAPE") //NGServer
                {
                    sUserConnectString = NGDbFactory.Instance.ComboOleDbConnString(sDbName);
                }
            }
            else if (dbcType == DBCType.OracleClient) //OracleClient
            {
                sDbLogPass         = this.GetOracleUserPassWord(ucode);
                sUserConnectString = NGDbFactory.Instance.ComboOracleConnString(sServerName, sDbName, sDbLogPass, "");
            }
            if (dbcType == DBCType.AseClient)//AseClient
            {
                sUserConnectString = "ConnectType=AseClient;" + string.Format("Data Source={0};Port={1};UID={2};PWD={3};Database={4};", sServerName, "5000", sDbLogID, sDbLogPass, sDbName);
            }
            else if (dbcType == DBCType.Odbc) //ODBC
            {
                string sDsn = this.GetDbName(ucode);
                sUserConnectString = "Dsn=" + sDsn;
            }
            if (!sUserConnectString.StartsWith("ConnectType=", StringComparison.CurrentCultureIgnoreCase))
            {
                sUserConnectString = "ConnectType=" + dbcType.ToString() + ";" + sUserConnectString;
            }
            return(sUserConnectString);
        }
Exemple #13
0
 public DbFactory(DbVendor vendor, string connstr, bool openTx)
 {
 }
Exemple #14
0
 public CRUD(DbVendor vendor, string connstr, bool openTx) : base(vendor, connstr, openTx)
 {
 }