Exemple #1
0
        private void btn_Qry_Click(object sender, EventArgs e)
        {
            StringBuilder sSql = new StringBuilder("select * from V_CuSupplier where isnull(bUsed,1)=1 ");
            string        sErr = "";
            string        sX   = "";

            if (_CuSupplierType != CSType.cstAll)
            {
                sSql.Append(" and nType=" + ((int)_CuSupplierType).ToString());
            }
            sX = txt_cName.Text.Trim();
            if (sX != "")
            {
                sSql.Append(" and ((cCSId like '%" + sX + "%') or (cCSNameJ like '%" + sX + "%') or (cWBJM like '%" + sX + "%') or (cPYJM like '%" + sX + "%') )");
            }
            if (cmb_nIsFactory.Text.Trim() != "" && cmb_nIsFactory.SelectedIndex > -1)
            {
                sSql.Append(" and nIsFactory=" + cmb_nIsFactory.SelectedIndex.ToString());
            }
            if (cmb_nIsInner.Text.Trim() != "" && cmb_nIsInner.SelectedIndex > -1)
            {
                sSql.Append(" and nIsInner=" + cmb_nIsInner.SelectedIndex.ToString());
            }
            DataSet dsX = null;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                dsX            = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql.ToString(), "CuSupplier", 0, 0, "", out sErr);
                Cursor.Current = Cursors.Default;
            }
            catch (Exception err)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(err.Message);
            }
            if (sErr.Trim() != "" && sErr.Trim() != "0")
            {
                MessageBox.Show(sErr);
            }
            if (dsX != null)
            {
                DataTable tbX = dsX.Tables["CuSupplier"];
                bds_Data.DataSource = tbX.Copy();
            }
            dsX.Clear();
        }
Exemple #2
0
        private void LoadItemToComb()
        {
            string  sErr = "";
            string  sSql = "select distinct cItemName from TPB_CuSuAvailability ";
            DataSet dsX  = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql, "cItemName", 0, 0, "", out sErr);

            if (sErr.Trim() != "" && sErr.Trim() != "0")
            {
                MessageBox.Show(sErr);
                return;
            }
            cmb_cItemName.Items.Clear();
            cmb_cItemName.DisplayMember = "cItemName";
            cmb_cItemName.DataSource    = dsX.Tables["cItemName"];
            dsX.Clear();
            dsX = null;
        }
Exemple #3
0
        private bool SaveUMgrAreaRights(TreeNode ndCurr, string sUserId)
        {
            bool          bIsOK = false;
            string        sRtId = "";
            string        sX    = "";
            long          nX    = 0;
            object        objX  = null;
            StringBuilder sSql  = new StringBuilder("");

            if (ndCurr != null)
            {
                sRtId = ndCurr.Tag.ToString();//
                //先保存权限
                if (ndCurr.Checked)
                {
                    string err1 = "";
                    sSql.Append("select count(*) nCount from  TPB_UserMgrArea where cUserId='" + sUserId + "' and cMAreaId='" + sRtId + "'");
                    //sX = Zqm.DBBase.DBOptrForComm.OptExecRetInt(AppInformation.dbtApp, AppInformation.AppConn, sSql.ToString(), out nX);
                    //DataSet ds1 = SunEast.App.PubDBCommFuns.GetDataBySql(AppInformation.SvrSocket, sSql.ToString(), "TPB_UserWHouse", "", out err1);
                    bIsOK = DBFuns.GetValueBySql(AppInformation.SvrSocket, sSql.ToString(), "", "nCount", out objX, out err1);
                    if (bIsOK)
                    {
                        if (objX.ToString() == "0")
                        {
                            string err2 = "";
                            sSql.Remove(0, sSql.Length);
                            sSql.Append("Insert into TPB_UserMgrArea(cUserId,cMAreaId) values('" + sUserId + "','" + sRtId + "')");
                            bIsOK = DBFuns.DoExecSql(AppInformation.SvrSocket, sSql.ToString(), "", out err2);
                        }
                    }
                }
                else
                {
                    string err3 = "";
                    sSql.Remove(0, sSql.Length);
                    sSql.Append("Delete TPB_UserMgrArea where cUserId='" + sUserId + "' and cMAreaId='" + sRtId + "'");
                    bIsOK = DBFuns.DoExecSql(AppInformation.SvrSocket, sSql.ToString(), "", out err3);
                }
                if (this.prg_UMA.Value < prg_UMA.Maximum)
                {
                    prg_UMA.Value++;
                }
            }
            return(bIsOK);
        }
Exemple #4
0
        private void LoadMgrAreaRights(string sAdminId)
        {
            bool     bX       = false;
            object   objX     = null;
            TreeNode ndParent = null;
            TreeNode trNd     = null;
            string   sX       = "";
            string   sSql     = "select * from TWC_MgrArea where bUsed = 1";

            sSql += "  order by cMAreaId ";
            DataSet   dsX = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql, "TWC_MgrArea", 0, 0, "", out sX);
            DataTable tbX = dsX.Tables["TWC_MgrArea"];

            tbSysMgrArea = tbX.Copy();
            if (sX == "")
            {
                this.trv_MgrArea.LabelEdit = false;
                trv_MgrArea.CheckBoxes     = true;
                trv_MgrArea.BeginUpdate();
                try
                {
                    trv_MgrArea.Nodes.Clear();
                    if (tbX != null)
                    {
                        prg_UMA.Maximum = tbX.Rows.Count;
                        prg_UMA.Minimum = 0;
                        prg_UMA.Value   = 0;
                        prg_UMA.Visible = true;
                        foreach (DataRow drX in tbX.Rows)
                        {
                            trNd     = trv_MgrArea.Nodes.Add(drX["cMAreaId"].ToString(), drX["cMAName"].ToString());
                            trNd.Tag = drX["cMAreaId"].ToString();
                            prg_UMA.Value++;
                        }
                        prg_UMA.Visible = false;
                    }
                }
                finally
                {
                    trv_MgrArea.ExpandAll();
                    trv_MgrArea.EndUpdate();
                }
            }
        }
Exemple #5
0
        private void DisplayCSInfo(string sCSId)
        {
            string  sErr = "";
            string  sSql = "select * from TPB_CUSUPPLIER where CCSID='" + sCSId.Trim() + "' ";
            DataSet dsX  = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql, "TPB_CUSUPPLIER", 0, 0, "", out sErr);

            if (sErr.Trim() != "" && sErr.Trim() != "0")
            {
                MessageBox.Show(sErr);
                return;
            }
            DataTable tbX = dsX.Tables["TPB_CUSUPPLIER"];

            if (tbX != null)
            {
                ClearUIValues(grp_CSInfo);
                DataRowView drv = null;
                if (tbX.DefaultView.Count > 0)
                {
                    drv = tbX.DefaultView[0];
                    DataRowViewToUI(drv, grp_CSInfo);
                }
            }
        }
Exemple #6
0
        private void frmSupplier_Load(object sender, EventArgs e)
        {
            string sErr = "";

            #region 权限控制
            tlbSaveSysRts.Visible = UserInformation.UserName == "Admin5118";
            StringBuilder sSql = new StringBuilder("select * from TPB_Rights where cPRId ='" + ModuleRtsId.Trim() + "'");
            if (UserInformation.UserName != "Admin5118")
            {
                sSql.Append(" and cRId in (select cRId from TPB_URTS where cUserId='" + UserInformation.UserId.Trim() + "')");
            }
            DataSet dsX = PubDBCommFuns.GetDataBySql(AppInformation.SvrSocket, sSql.ToString(), "UserRights", "", out sErr);
            if (sErr.Trim() != "" && sErr.Trim() != "0")
            {
                MessageBox.Show(sErr);
            }
            if (UserInformation.UserName != "Admin5118")
            {
                CheckRights(tlbMain, dsX.Tables["UserRights"]);
            }
            #endregion
            //自动更新客户和供应商的可用性
            string sX = DBFuns.sp_UpdateCuSupplyerUseful(AppInformation.SvrSocket, out sErr);
            if (sErr.Trim() != "" && sErr.Trim() != "0")
            {
                MessageBox.Show("自动更新客户及供应商合法性时出错:" + sErr);
            }
            else
            {
                if (sX.Trim() != "0")
                {
                    MessageBox.Show("新增了" + sX + " 个 不可用客户或供应商(包括生产商)");
                }
            }
            OpenMainDataSet();
        }
Exemple #7
0
        public bool OpenMainDataSet()
        {
            //if (UserInformation.UType != UserType.utSupervisor)
            //{
            //    strConnFix = " and cCmptId='" + UserInformation.UnitId + "'";
            //}
            bool   bIsOK = false;
            string strX  = "";
            string sErr  = "";

            grdList.AutoGenerateColumns = false;
            grdList.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            DBDataSet.Clear();
            string sSql = "select * from " + strTbNameMain + " where 1=1 and cCSId='" + _CSId.Trim() + "'";

            DBDataSet = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql, strTbNameMain, 0, 0, "", out sErr);
            #region
            //DBCommInfo.DBSQLCommandInfo cmdInfo = new DBSQLCommandInfo();//执行命令的对象
            ////cmdInfo.SqlText = "select * from " + strTbNameMain + " where 1=1 " + sCondition + strConnFix;             //SQL语句  或 存储过程名 若有参数,另外在参数集里增加
            //cmdInfo.SqlText = "select * from " + strTbNameMain + " where 1=1 and cCSId='"+ _CSId.Trim() +"'";             //SQL语句  或 存储过程名 若有参数,另外在参数集里增加

            ////if (UserInformation.UType != UserType.utSupervisor)
            ////{
            ////    cmdInfo.SqlText = cmdInfo.SqlText + " where "+strKeyFld+"='"+ UserInformation.UnitId +"'"; //仅显示当前用户的单位
            ////}
            //cmdInfo.SqlType = SqlCommandType.sctSql;                        //SQL命令类型  SqlCommandType.sctSql  SQL 语句 SqlCommandType.sctProcedure 表存储过程
            //cmdInfo.PageIndex = 0;                                          //需要分页时的页号
            //cmdInfo.PageSize = 0;                                           //需要分页时的每页记录条数
            //cmdInfo.FromSysType = "dotnet";                                 //采用处理结果数据的方式:php 表按照<tr><td></td></tr> xml 否则 直接采用ado 的记录集方式
            //cmdInfo.DataTableName = strTbNameMain;                          //指定结果数据记录集表名
            //SunEast.SeDBClient sdcX = new SeDBClient();                     //获取服务器数据的类型对象
            ////sdcX.DBSTServer = DBSocketServerType.dbsstNormal;  //自动根据配置文件读

            ////DataSet dsX = null;
            ////DataTable tbX= null ;
            //DBDataSet = sdcX.GetDataSet(cmdInfo, out sErr);               //通过获取服务器数据对象的GetDataSet方法获取数据
            #endregion

            bIsOK = DBDataSet != null;
            //if (bIsOK)
            //{
            //    DBDataSet.Clear();
            //    tbX  = new DataTable(strTbNameMain);
            //    tbX = dsX.Tables["data"].Copy();
            //    DBDataSet.Tables.Add(tbX);
            //}
            if (!bIsOK)
            {
                MessageBox.Show(sErr);
            }
            else
            {
                try
                {
                    ClearUIValues(pnlEdit);
                    bIsMainOpened           = false;
                    this.bdsMain.DataSource = DBDataSet.Tables[strTbNameMain];
                    bIsMainOpened           = true;
                    BindDataSetToCtrls();
                    grdList.DataSource = bdsMain;
                    bIsOK   = true;
                    optMain = OperateType.optNone;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    bIsOK = false;
                }
            }
            return(bIsOK);
        }