コード例 #1
0
ファイル: login.aspx.cs プロジェクト: zlpatrick/airmaster
        protected void loginButton_Click(object sender, EventArgs e)
        {
            string usermobile = this.memberId.Text.Trim();
            string userepassword = this.password.Text.Trim();

            string sql = string.Format("select * from Users where usermobile='{0}'", usermobile);
            DBUtil db = new DBUtil();
            DataSet ds = db.executeQuery(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string psword = ds.Tables[0].Rows[0]["userpassword"].ToString();
                string md5pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userepassword, "MD5");
                if (md5pass.Equals(psword))
                {
                    Session["userid"] = usermobile;
                    Response.Redirect("index.aspx");
                }
            }
        }
コード例 #2
0
ファイル: reg.aspx.cs プロジェクト: zlpatrick/airmaster
        protected void regButton_Click(object sender, EventArgs e)
        {
            string mobile = this.memberId.Text.Trim();
            string password = this.password.Text.Trim();

            string sql = string.Format("select * from Users where usermobile='{0}'", mobile);
            DBUtil db = new DBUtil();
            DataSet ds = db.executeQuery(sql);
            string passwordMD5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5");
            if (ds.Tables[0].Rows.Count > 0)
            {
                //already registed
            }
            else
            {
                sql = string.Format("insert into Users(usermobile,userpassword) values('{0}','{1}')", mobile, passwordMD5);
                db.executeNonQuery(sql);
                Session["userid"] = mobile;
                Response.Redirect("index.aspx");
            }
        }
コード例 #3
0
ファイル: SrvUser.cs プロジェクト: jehan2898/root
        public gbmodel.user.User Authenticate(gbmodel.user.User p_oUser)
        {
            List <SqlParameter> oParams = new List <SqlParameter>();

            oParams.Add(new SqlParameter("@username", p_oUser.UserName));
            oParams.Add(new SqlParameter("@password", GetEncryptedString(p_oUser.Password)));

            DataSet ds        = null;
            string  sUserName = null;
            string  sUserID   = null;

            gbmodel.user.User oUser = null;

            ds = DBUtil.DataSet(Procedures.PR_AUTHENTICATION, oParams);

            if (ds.Tables[0].Rows.Count == 0)
            {
                throw new AuthenticationException("Invalid username or password");
            }

            sUserName = ds.Tables[0].Rows[0]["username"].ToString();
            sUserID   = ds.Tables[0].Rows[0]["ID"].ToString();

            if (sUserID != null && sUserName != null && sUserID.Trim().Length != 0 && sUserName.Trim().Length != 0)
            {
                oParams = new List <SqlParameter>();
                oParams.Add(new SqlParameter("@sz_user_name", p_oUser.UserName));
                oParams.Add(new SqlParameter("@flag", "CHECKLOGIN"));

                // get the user object
                ds = DBUtil.DataSet(Procedures.PR_DOCTOR_LOGIN_PARAMETERS, oParams);

                oUser          = new gbmodel.user.User();
                oUser.ID       = sUserID;
                oUser.UserName = sUserName;
                oUser.Domain   = ds.Tables[0].Rows[0]["DomainName"].ToString();
                oUser.Email    = ds.Tables[0].Rows[0]["user_email_id"].ToString();

                gbmodel.account.Account oAccount = new gbmodel.account.Account();

                try
                {
                    oAccount.ID   = ds.Tables[0].Rows[0]["sz_company_id"].ToString();
                    oAccount.Name = ds.Tables[0].Rows[0]["sz_company_name"].ToString();
                }
                catch (IndexOutOfRangeException _x)
                {
                    throw new IncompleteDataException("Account data not found for your user account");
                }

                if (oAccount.ID == null || oAccount.Name == null || oAccount.ID == "" || oAccount.Name == "")
                {
                    throw new IncompleteDataException("Account data not set for your user account");
                }

                gbmodel.user.Role oRole = new gbmodel.user.Role();
                oRole.ID   = ds.Tables[0].Rows[0]["sz_user_role"].ToString();
                oRole.Name = ds.Tables[0].Rows[0]["sz_user_role_name"].ToString();

                if (oRole.ID == null || oRole.Name == null || oRole.ID == "" || oRole.Name == "")
                {
                    throw new IncompleteDataException("User role data not found");
                }

                oUser.Account = oAccount;
                oUser.Role    = oRole;
                oUser.Token   = GenerateUserToken(oUser.UserName, oUser.Domain);
            }
            else
            {
                throw new AuthenticationException("Invalid username or password");
            }
            return(oUser);
        }
コード例 #4
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        int    CountyID = 0;
        int    TownID   = 0;
        string BirthDateS;
        string BirthDateE;
        string CaseName;
        string CaseIdNo;
        string SearchReason;
        string SearchConditions = "";
        string ReportFields     = "";
        int    SearcResultCount = 0;
        int    IsSearch         = 0;
        int    SearchKind       = 3;

        BirthDateS = Request.Form["BirthDateS"] ?? "";
        BirthDateE = Request.Form["BirthDateE"] ?? "";
        if (BirthDateS != "")
        {
            try
            {
                BirthDateS = TaiwanYear.ToDateTime(BirthDateS).ToString("yyyyMMdd");
            }
            catch
            {
                BirthDateS = "";
            }
        }
        if (BirthDateE != "")
        {
            try
            {
                BirthDateE = TaiwanYear.ToDateTime(BirthDateE).ToString("yyyyMMdd");
            }
            catch
            {
                BirthDateE = "";
            }
        }

        CaseName = Request.Form["CaseName"] ?? "";
        CaseIdNo = Request.Form["CaseIdNo"] ?? "";
        int.TryParse(Request.Form["CountyID"], out CountyID);
        int.TryParse(Request.Form["TownID"], out TownID);
        int.TryParse(Request.Form["IsSearch"], out IsSearch);
        SearchReason = Request.Form["SearchReason"] ?? "";
        foreach (ListItem item in cblReportFields.Items)
        {
            if (item.Selected)
            {
                ReportFields += item.Value + ",";
            }
        }
        ReportFields = ReportFields.TrimEnd(',');

        // Response.Write(string.Format("exec dbo.usp_CaseUser_xGetUserListExport {0},{1},{2},{3},{4},{5},{6} ", CaseName, CaseIdNo, BirthDateS, BirthDateE, CountyID.ToString(), TownID.ToString(), ReportFields));
        //  Response.Write(ReportFields);
        DataTable dt = new DataTable();

        try
        {
            dt = (DataTable)DBUtil.DBOp("ConnDB", "exec dbo.usp_CaseUser_xGetUserListExport {0},{1},{2},{3},{4},{5},{6} ", new string[] { CaseName, CaseIdNo, BirthDateS, BirthDateE, CountyID.ToString(), TownID.ToString(), ReportFields }, NSDBUtil.CmdOpType.ExecuteReaderReturnDataTable);

            SearcResultCount = dt.Rows.Count;
        }
        catch
        {
        }
        finally {
            DBUtil.DBOp("ConnDB", " exec [dbo].[usp_CaseUser_xAddSearchLog] {0}, {1}, {2} ,{3} ,{4}", new string[] { AuthServer.GetLoginUser().ID.ToString(), SearchConditions, SearchReason, SearcResultCount.ToString(), SearchKind.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery);
        }
        ExportToFile etf = new ExportToFile();

        etf.ExporttoExcel(dt, "批次資料勾稽");
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.AllowHttpMethod("POST");
        base.DisableTop(true);
        int    pgNow;
        int    pgSize;
        int    CountyID = 0;
        int    TownID   = 0;
        string BirthDateS;
        string BirthDateE;
        string CaseName;
        string CaseIdNo;
        string SearchReason;
        string SearchConditions = "";
        int    SearcResultCount = 0;
        int    IsSearch         = 0;
        int    SearchKind       = 3;


        BirthDateS = Request.Form["BirthDateS"] ?? "";
        BirthDateE = Request.Form["BirthDateE"] ?? "";
        if (BirthDateS != "")
        {
            try
            {
                //BirthDateS = Convert.ToDateTime(BirthDateS).ToString("yyyyMMdd");
                BirthDateS = TaiwanYear.ToDateTime(BirthDateS).ToString("yyyyMMdd");
            }
            catch {
                BirthDateS = "";
            }
        }
        if (BirthDateE != "")
        {
            try
            {
                // BirthDateE = Convert.ToDateTime(BirthDateE).ToString("yyyyMMdd");
                BirthDateE = TaiwanYear.ToDateTime(BirthDateE).ToString("yyyyMMdd");
            }
            catch
            {
                BirthDateE = "";
            }
        }

        CaseName = Request.Form["CaseName"] ?? "";
        CaseIdNo = Request.Form["CaseIdNo"] ?? "";


        int.TryParse(Request.Form["pgNow"], out pgNow);
        int.TryParse(Request.Form["pgSize"], out pgSize);
        int.TryParse(Request.Form["CountyID"], out CountyID);
        int.TryParse(Request.Form["TownID"], out TownID);
        int.TryParse(Request.Form["IsSearch"], out IsSearch);
        SearchReason = Request.Form["SearchReason"] ?? "";


        List <UserProfileListVM> list = new List <UserProfileListVM>();
        PageVM  rtn = new PageVM();
        DataSet ds  = new DataSet();


        try
        {
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("dbo.usp_CaseUser_xGetUserList", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@pgNow", pgNow == 0 ? 1 : pgNow);
                    cmd.Parameters.AddWithValue("@pgSize", pgSize == 0 ? 10 : pgSize);
                    cmd.Parameters.AddWithValue("@BirthDateS", BirthDateS);
                    cmd.Parameters.AddWithValue("@BirthDateE", BirthDateE);
                    cmd.Parameters.AddWithValue("@CaseName", CaseName);
                    cmd.Parameters.AddWithValue("@CaseIdNo", CaseIdNo);
                    cmd.Parameters.AddWithValue("@CountyID", CountyID);
                    cmd.Parameters.AddWithValue("@TownID", TownID);
                    //cmd.Parameters.AddWithValue("@IsSearch", IsSearch);
                    //cmd.Parameters.AddWithValue("@SearchReason", SearchReason);

                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        sc.Open();
                        da.Fill(ds);
                    }
                }
            }

            SearcResultCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);

            EntityS.FillModel(list, ds.Tables[0]);
            EntityS.FillModel(rtn, ds.Tables[1]);
        }
        catch
        {
        }
        finally {
            //記下查詢紀錄

            if (IsSearch == 1)
            {
                if (CaseName != "")
                {
                    SearchConditions += "姓名:" + CaseName;
                }
                if (CaseIdNo != "")
                {
                    SearchConditions += "身份證號:" + CaseIdNo;
                }
                if (BirthDateS != "")
                {
                    SearchConditions += "生日起日:" + BirthDateS;
                }
                if (BirthDateE != "")
                {
                    SearchConditions += "生日迄日:" + BirthDateE;
                }
                if (CountyID != 0)
                {
                    SearchConditions += "戶籍縣市:" + SystemAreaCode.GetName(CountyID);
                }
                if (TownID != 0)
                {
                    SearchConditions += "戶籍鄉鎮:" + SystemAreaCode.GetName(TownID);
                }

                Session["SearchID"] = Convert.ToInt32(DBUtil.DBOp("ConnDB", " exec [dbo].[usp_CaseUser_xAddSearchLog] {0}, {1}, {2} ,{3} ,{4}", new string[] { AuthServer.GetLoginUser().ID.ToString(), SearchConditions, SearchReason, SearcResultCount.ToString(), SearchKind.ToString() }, NSDBUtil.CmdOpType.ExecuteScalar));
            }
        }
        rtn.message = list;

        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn));
        Response.End();
    }
コード例 #6
0
        public static bool InsertNewItemType(ItemType item)
        {
            //Create the objects we need to insert a new record
            OleDbConnection cnInsert  = new OleDbConnection(DBUtil.GetConnectionString());
            OleDbCommand    cmdInsert = new OleDbCommand();
            string          query     = " INSERT INTO ItemType(Name,Price, Sale_Price, UoM_ID, Vendor_ID) ";

            query += " VALUES(@name, @price, @salePrice, @uomId, @vendorId)";

            int iSqlStatus;

            //Clear any parameters
            cmdInsert.Parameters.Clear();
            try
            {
                //Set the OleDbCommand Object Properties

                //Tell it what to execute
                cmdInsert.CommandText = query;
                //Tell it its a text query
                cmdInsert.CommandType = CommandType.Text;
                //Now add the parameters to our query
                //NOTE: Replace @value1.... with your parameter names in your query
                //and add all your parameters in this fashion
                cmdInsert.Parameters.AddWithValue("@name", item.ItemName);
                cmdInsert.Parameters.AddWithValue("@price", item.Price);
                cmdInsert.Parameters.AddWithValue("@salePrice", item.SalePrice);
                cmdInsert.Parameters.AddWithValue("@uomId", item.Uom.Id);
                cmdInsert.Parameters.AddWithValue("@vendorId", item.Vendor.Id);

                //Set the connection of the object
                cmdInsert.Connection = cnInsert;


                //Now take care of the connection
                DBUtil.HandleConnection(cnInsert);
                //Set the iSqlStatus to the ExecuteNonQuery
                //status of the insert (0 = failed, 1 = success)
                iSqlStatus = cmdInsert.ExecuteNonQuery();

                //Now check the status
                if (iSqlStatus == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                //Now close the connection
                DBUtil.HandleConnection(cnInsert);
                long maxId = DBUtil.GetMaxID("Type_ID", "ItemType");
                ShopDAL.insertValueOfStockInHand(cnInsert, maxId);
            }
        }
コード例 #7
0
ファイル: CompraDao.cs プロジェクト: LucasPMedeiros/Universo
 //--------------------------------------------------------
 public static long getLastId()
 {
     return(DBUtil.getLastId("compra"));
 }
コード例 #8
0
        /// <summary>
        /// Single reusable function for create/adding and updating questions
        /// </summary>
        /// <param name="model">Question to be updated</param>
        /// <param name="WriteType"> 1: Create, 2: Update </param>
        /// <returns> Status of write </returns>
        public DataSet WriteQuestion(Question model, int WriteType, Controller _Controller)
        {
            var UserNumber = _Controller.User.Identity.GetCurUserNumber();

            DBUtil       objDBUtil = new DBUtil(3);
            MySqlCommand cmd       = null;

            #region Assign field values

            string[] Q_FieldsArr = model.Q_Fields.SanitizeInput().Split(',');
            if (Q_FieldsArr.Length > 0)
            {
                model.Q_F1 = Q_FieldsArr[0];
            }
            else
            {
                model.Q_F1 = "none";
            }

            if (Q_FieldsArr.Length > 1)
            {
                model.Q_F2 = Q_FieldsArr[1];
            }
            else
            {
                model.Q_F2 = "none";
            }

            if (Q_FieldsArr.Length > 2)
            {
                model.Q_F3 = Q_FieldsArr[2];
            }
            else
            {
                model.Q_F3 = "none";
            }

            if (Q_FieldsArr.Length > 3)
            {
                model.Q_F4 = Q_FieldsArr[3];
            }
            else
            {
                model.Q_F4 = "none";
            }

            if (Q_FieldsArr.Length > 4)
            {
                model.Q_F5 = Q_FieldsArr[4];
            }
            else
            {
                model.Q_F5 = "none";
            }

            #endregion

            model.Q_WikiHtml = model.Q_Wiki.ConvertMdToHtml();

            if (WriteType == 1)
            {
                cmd = new MySqlCommand("spAddQuestion");
                cmd.Parameters.AddWithValue("pQ_By", UserNumber);
            }
            else if (WriteType == 2)
            {
                cmd = new MySqlCommand("spUpdateQuestion");
                cmd.Parameters.AddWithValue("pQuestionId", model.QuestionId);
                cmd.Parameters.AddWithValue("pQ_EditBy", UserNumber);
                cmd.Parameters.AddWithValue("pQ_EditSummary", model.Q_EditSummary);
            }

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("pQ_Title", model.Q_Title.SanitizeInput());
            cmd.Parameters.AddWithValue("pQ_Wiki", model.Q_Wiki.SanitizeInput());
            cmd.Parameters.AddWithValue("pQ_WikiHtml", model.Q_WikiHtml);
            cmd.Parameters.AddWithValue("pQ_Fields", model.Q_Fields);
            cmd.Parameters.AddWithValue("pQ_F1", model.Q_F1);
            cmd.Parameters.AddWithValue("pQ_F2", model.Q_F2);
            cmd.Parameters.AddWithValue("pQ_F3", model.Q_F3);
            cmd.Parameters.AddWithValue("pQ_F4", model.Q_F4);
            cmd.Parameters.AddWithValue("pQ_F5", model.Q_F5);
            DataSet AddQuestion = objDBUtil.FillDataSet(cmd);

            return(AddQuestion);
        }
コード例 #9
0
 public Task GetTask(int id)
 {
     return(DBUtil.SelectOne <Task>("SELECT B.USERNAME + '/' + CAST( B.ID as varchar ) AS USERNAME, A.* FROM TASK A, USERINFO B WHERE A.ID = '" + id + "' AND A.USERINFO_ID = B.ID"));
 }
コード例 #10
0
ファイル: ManagerDAL.cs プロジェクト: NingMoe/UniICWeb
 /// <summary>
 /// 通过主键删除管理员
 /// </summary>
 /// <param name="key">主键</param>
 /// <returns></returns>
 public bool DeleteManagerByKey(int key)
 {
     SqlParameter[] array = { new SqlParameter("@managerid", key) };
     return(DBUtil.ExecuteNonQuery(SQL_deleteManagerByKey, array) > 0);
 }
コード例 #11
0
ファイル: ManagerDAL.cs プロジェクト: NingMoe/UniICWeb
        /// <summary>
        /// 获取全部管理员
        /// </summary>
        /// <returns></returns>
        public DataSet GetManagers()
        {
            DataSet ds = DBUtil.ExecuteQuery(SQL_getManagers);

            return(ds);
        }
コード例 #12
0
        public void Parse(string fileName)
        {
            Application xlApp;
            Workbook    xlWorkBook;
            Worksheet   xlWorkSheet;

            ADOTemplate template = new ADOTemplate();

            xlApp      = new ApplicationClass();
            xlWorkBook = xlApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

            for (int iSheet = 1; iSheet <= xlWorkBook.Worksheets.Count; iSheet++)
            {
                xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(iSheet);
                range       = xlWorkSheet.UsedRange;

                rowCount = range.Rows.Count;
                if (rowCount < 2)
                {
                    continue;
                }

                colCount = range.Columns.Count;

                this.ReadConfig();

                this.ReadColumns();

                IDbTransaction Transaction = null;
                using (IDbConnection connection = DBUtil.GetConnection(dbName))
                {
                    try
                    {
                        connection.Open();

                        Transaction = connection.BeginTransaction();

                        new TransactionContext(connection, Transaction, ConfigCache.GetDBType(dbName));

                        for (int iRow = 2; iRow <= rowCount; iRow++)
                        {
                            Hashtable data = this.ReadDataRow(iRow);

                            string op = (string)data["$op"];

                            if ("s".Equals(op))
                            {
                                template.Execute((string)data["$sql"], null, null);
                            }
                            else if ("i".Equals(op))
                            {
                                template.Execute(this.insertSql, data);
                            }
                            else if ("d".Equals(op))
                            {
                                template.Execute(this.deleteSql, data);
                            }
                        }

                        Transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        if (Transaction != null)
                        {
                            Transaction.Rollback();
                        }
                        throw e;
                    }
                    finally
                    {
                        if (connection != null && ConnectionState.Open == connection.State)
                        {
                            connection.Close();
                        }
                    }
                }

                ReleaseObject(xlWorkSheet);
            }

            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            ReleaseObject(xlWorkBook);
            ReleaseObject(xlApp);
        }
コード例 #13
0
        private void populatePanel2()
        {
            //generate list of barcodes from 00001 to 00796
            string        barcode = "00001";
            StringBuilder sb      = new StringBuilder();

            sb.Append(barcode);
            while (barcode != "007C9")
            {
                barcode = Tools.IncrementBarcode(barcode, 1, barcode.Length);
                sb.Append("," + barcode);
            }
            List <string> barcodeList = sb.ToString().Split(',').ToList();

            //get data from database
            DataTable dt = DBUtil.getData(string.Format(@"
	            SELECT barcode AS Barcode, 
			            Inventory.code AS CODE,
                        item_length AS Qty, 
			            ProductWidths.product_width_name AS 'lebar (cm)', 
			            Products.name_store AS Product,
			            Grades.grade_name AS Grade,
			            Colors.color_name AS Warna
	            FROM ((((((InventoryItems 
		            LEFT OUTER JOIN Inventory ON Inventory.id = InventoryItems.inventory_id
		            ) LEFT OUTER JOIN Products ON Products.id = Inventory.product_id
		            ) LEFT OUTER JOIN ProductWidths ON ProductWidths.id = Inventory.product_width_id
		            ) LEFT OUTER JOIN LengthUnits ON LengthUnits.id = Inventory.length_unit_id
		            ) LEFT OUTER JOIN Grades ON Grades.id = Inventory.grade_id
		            ) LEFT OUTER JOIN Colors ON Colors.id = Inventory.color_id
		            ) LEFT OUTER JOIN ProductPrices
			            ON (ProductPrices.product_id = Inventory.product_id
				            AND ProductPrices.grade_id = Inventory.grade_id
				            AND ProductPrices.product_width_id = Inventory.product_width_id
				            AND ProductPrices.length_unit_id = Inventory.length_unit_id)"                ));

            Tools.setDataTablePrimaryKey(dt, "Barcode");

            List <string> missingBarcodeList = new List <string>();
            DataTable     dtMissing          = new DataTable();

            Tools.addColumn <string>(dtMissing, "barcode", null);
            for (int i = barcodeList.Count - 1; i > -1; i--)
            {
                if (!dt.Rows.Contains(barcodeList[i]))
                {
                    dtMissing.Rows.Add(barcodeList[i]);
                }
            }

            //display in gridview
            gridBarcodesNotInDB.DataSource = dtMissing;

            //SELECT barcode AS Barcode,
            //        Inventory.code AS CODE,
            //        item_length AS Qty,
            //        ProductWidths.product_width_name AS 'lebar (cm)',
            //        Products.name_store AS Product,
            //        Grades.grade_name AS Grade,
            //        Colors.color_name AS Warna

            //remove from list


            //SELECT InventoryItems.id,inventory_id,item_length, barcode,InventoryItems.notes,
            //        Inventory.code AS inventory_code,
            //        ProductWidths.product_width_name AS product_width_name,
            //        Products.name_store AS product_name_store,
            //        ProductPrices.tag_price AS tag_price,
            //        LengthUnits.length_unit_name AS length_unit_name,
            //        Grades.grade_name AS grade_name,
            //        Colors.color_name AS color_name
        }
コード例 #14
0
        //*******************************************************************
        /// <summary>情報エリアをセット(編集、コピー新規用)</summary>
        //*******************************************************************
        private void SetInfoArea()
        {
            DataRow row = container.ScheduleControlTable.Select()[0];

            //コピー新規の場合、採番したデフォルトIDをセット
            if (_editType == Consts.EditType.CopyNew)
            {
                tbxScheduleId.Text = "SCHEDULE_" + DBUtil.GetNextId("102");
                // スケジュール名をセット
                tbScheduleName.Text = Convert.ToString(row["schedule_name"]);
            }
            else
            {
                // スケジュールIDをセット
                tbxScheduleId.Text = Convert.ToString(row["schedule_id"]);
                // スケジュールIDのテキストボックスをグレーアウトし、編集不可の状態とする
                tbxScheduleId.IsEnabled = false;
                // スケジュール名をセット
                tbScheduleName.Text = oldScheduleName = Convert.ToString(row["schedule_name"]);
            }

            // 公開チェックボックス
            int openFlg = Convert.ToInt16(row["public_flag"]);

            if (openFlg == 0)
            {
                cbOpen.IsChecked = oldPublicFlg = false;
            }
            else if (openFlg == 1)
            {
                cbOpen.IsChecked = oldPublicFlg = true;
            }

            // 権限が運用の場合
            if (Consts.ActionMode.USE == LoginSetting.Mode || _editType == Consts.EditType.READ)
            {
                SetUseMode();
                powerLabel.Content = Properties.Resources.can_not_update_auth;
            }

            // 説明
            tbComment.Text = oldComment = Convert.ToString(row["memo"]);
            //ユーザー名
            if (_editType == Consts.EditType.CopyNew)
            {
                lblUserName.Content = LoginSetting.UserName;
            }
            else
            {
                lblUserName.Content = Convert.ToString(row["user_name"]);
            }

            //更新日
            if (_editType == Consts.EditType.READ || _editType == Consts.EditType.Modify)
            {
                lblUpdDate.Content = ConvertUtil.ConverIntYYYYMMDDHHMISS2Date(Convert.ToDecimal(row["update_date"])).ToString("yyyy/MM/dd HH:mm:ss");
            }
            else
            {
                lblUpdDate.Content = "";
            }
        }
コード例 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sql = BuildSearchSql();

            dt = DBUtil.Select(sql);
        }
コード例 #16
0
        private bool LoadCache(out Dictionary <int, Station> dicStations, out string err)
        {
            err         = "";
            dicStations = new Dictionary <int, Station>();

            #region 查询sensor表
            string    sqlSensors = @"select  x.*,x1.ID  pointID ,x1.*  from( select t.ID stationID,t.Name StationName ,t.FOPCDeviceName ,t.FOPCServerName,t.FPLCIP, t1.ID sensorID,t1.Name sensorName,t1.PointAddressID 
                                                 from SCADA_Station t ,SCADA_Sensor t1 where t.ID=t1.StationID and t.ReadMode='OPC'
                                                 and (t.是否删除=0 or t.是否删除 is null ) and (t1.是否删除=0 or t1.是否删除 is null )) x
                                              left join PointAddressEntry x1 on x.PointAddressID=x1.ID and x1.是否激活=1;";
            DataTable dtSensors  = DBUtil.ExecuteDataTable(sqlSensors, out string errMsg);
            if (!string.IsNullOrWhiteSpace(errMsg))
            {
                err = "查询sensor列表失败:" + errMsg;
                return(false);
            }
            foreach (DataRow dr in dtSensors.Rows)
            {
                Station station = new Station()
                {
                    _ID             = DataUtil.ToInt(dr["stationID"]),
                    _StationName    = DataUtil.ToString(dr["StationName"]),
                    _FOPCDeviceName = DataUtil.ToString(dr["FOPCDeviceName"]),
                    _FOPCServerName = DataUtil.ToString(dr["FOPCServerName"]),
                    _FPLCIP         = DataUtil.ToString(dr["FPLCIP"]),
                    sensors         = new List <Sensor>()
                };
                Sensor sensor = new Sensor()
                {
                    pointID           = DataUtil.ToInt(dr["pointID"]),
                    sensorID          = DataUtil.ToString(dr["sensorID"]),
                    sensorName        = DataUtil.ToString(dr["sensorName"]),
                    _PointAddressID   = DataUtil.ToInt(dr["PointAddressID"]),
                    versionID         = DataUtil.ToInt(dr["版本ID"]),
                    dataSourceAddress = DataUtil.ToString(dr["数据源地址"]).Trim(),
                    offsetAddress     = DataUtil.ToString(dr["偏移地址"]).Trim(),
                    type     = Point.ToType(DataUtil.ToString(dr["数据类型"])),
                    isActive = DataUtil.ToInt(dr["是否激活"]),
                    isWrite  = DataUtil.ToInt(dr["是否写入"]),
                    scale    = DataUtil.ToDouble(dr["倍率"])
                };
                // 站点-sensor入字典库
                if (dicStations.Keys.Contains(station._ID))
                {
                    dicStations[station._ID].sensors.Add(sensor);
                }
                else
                {
                    station.sensors.Add(sensor);
                    station.opc = this.opcClientManager.GetOPCClient(station._FOPCServerName); // 将站点的OPC对象赋值
                    if (station.Check(out errMsg))
                    {
                        dicStations.Add(station._ID, station);
                    }
                    else
                    {
                        TraceManagerForOPC.AppendWarning("StationID:" + station._ID + "环境异常:" + errMsg);
                    }
                }
            }
            if (dicStations.Keys.Count == 0)
            {
                err = "站点表明细没有关于OPC的站点表";
                return(false);
            }
            #endregion

            return(true);;
        }
コード例 #17
0
ファイル: registrySettings.cs プロジェクト: Jackjet/ECOSingle
 private void btnsaveDB_Click(object sender, System.EventArgs e)
 {
     if (!this.DBparaCheck())
     {
         return;
     }
     if (!this.checkBoxUseMySQL.Checked)
     {
         DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DB_ChangeCrm, new string[0]), MessageBoxButtons.OKCancel);
         if (dialogResult == DialogResult.Cancel)
         {
             return;
         }
         AccessDBUpdate.InitAccessDataDB();
         DBUtil.ChangeDBSetting2Access();
         base.DialogResult = DialogResult.OK;
         return;
     }
     else
     {
         string   text  = this.tbDBIP.Text;
         int      num   = System.Convert.ToInt32(this.tbDBPort.Text);
         string   text2 = this.tbDBUsrnm.Text;
         string   text3 = this.tbDBPsw.Text;
         string[] param = new string[]
         {
             text,
             this.tbDBPort.Text,
             text2,
             text3
         };
         progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_Checkdbconnect, new string[0]), null, new progressPopup.ProcessInThread(this.dbCheckParameter), param, 0);
         progressPopup.ShowDialog();
         object return_V = progressPopup.Return_V;
         int?   num2     = return_V as int?;
         if (!num2.HasValue)
         {
             num2 = new int?(DebugCenter.ST_Unknown);
         }
         if (num2 == DebugCenter.ST_Success)
         {
             DBUtil.ChangeDBSetting2MySQL(text, num, text2, text3, false);
             base.DialogResult = DialogResult.OK;
             return;
         }
         if (num2 == DebugCenter.ST_MYSQLCONNECT_ERROR || num2 == DebugCenter.ST_MYSQLAUTH_ERROR || num2 == DebugCenter.ST_Unknown)
         {
             EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.DB_Connectfail, new string[0]));
             return;
         }
         DialogResult dialogResult2 = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DBinitcrm_Master, new string[0]), MessageBoxButtons.OKCancel);
         if (dialogResult2 == DialogResult.Cancel)
         {
             return;
         }
         string dbname = "";
         int    num3   = DBMaintain.InitMySQLDatabase4Master(text, num, text2, text3, ref dbname);
         if (num3 > 0)
         {
             num3 = DBUtil.ChangeDBSetting2MySQL(dbname, text, num, text2, text3);
             if (num3 == 1)
             {
                 num3 = DebugCenter.ST_Success;
             }
         }
         if (num3 == DebugCenter.ST_Success)
         {
             base.DialogResult = DialogResult.OK;
             return;
         }
         EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0]));
         return;
     }
 }
コード例 #18
0
 public UserInfo getAssignerInfo(Task task)
 {
     return((UserInfo)DBUtil.SelectOneById <UserInfo>(task.Assignor));
 }
コード例 #19
0
        public static List <ContaReceber> BuscarTodos()
        {
            List <ContaReceber> contaRecebers = new List <ContaReceber>();

            try
            {
                SqlCommand cmd = new SqlCommand("select cr.id, cr.valor, cr.data, cr.id_venda from conta_receber as cr order by cr.id", DBUtil.getConnection());
                DBUtil.getConnection().Open();
                cmd.ExecuteNonQuery();
                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    contaRecebers.Add(getContaReceber(dt.Rows[i].ItemArray));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            finally
            {
                DBUtil.closeConnection();
            }
            return(contaRecebers);
        }
コード例 #20
0
        /// <summary>
        /// This method is used to update the data with the help of ProCustomerUpdateAll stored procedure.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            try
            {
                DBUtil dbobj1 = new DBUtil(System.Configuration.ConfigurationSettings.AppSettings["Servosms"], true);
                //InventoryClass obj1=new InventoryClass ();
                //SqlDataReader SqlDtr1=null;
                SqlDataReader rdr1       = null;
                int           Total_Cust = 0;
                //string prod_cat="",sql;
                //int flag = 0;
                //string j="";
                //int x=0;
                PartiesClass obj = new PartiesClass();
                Total_Cust = System.Convert.ToInt32(Request.Params.Get("Total_Cust"));
                int i = 0;
                for (int j = 0; j < Total_Cust; j++)
                {
                    i               = 0;
                    obj.Cust_ID     = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.sadbhavnacd = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.Cust_Name   = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.Address     = Request.Params.Get("txtInfo" + j + "To" + i++);
                    //obj.EMail=Request.Params.Get("txtInfo"+j+"To"+i++);
                    string type = Request.Params.Get("txtInfo" + j + "To" + i++);
                    if (type != "Select")
                    {
                        obj.Cust_Type = type;
                    }
                    else
                    {
                        obj.Cust_Type = "";
                    }
                    string ssr = Request.Params.Get("txtInfo" + j + "To" + i++);
                    if (ssr == "Select")
                    {
                        obj.SSR = "";
                    }
                    else
                    {
                        dbobj1.SelectQuery("select Emp_ID from Employee where Emp_Name='" + ssr + "'", ref rdr1);
                        if (rdr1.Read())
                        {
                            obj.SSR = rdr1["Emp_ID"].ToString();
                        }
                        else
                        {
                            obj.SSR = "";
                        }
                        rdr1.Close();
                    }
                    //obj.SSR=Request.Params.Get("txtInfo"+j+"To"+i++);
                    string city = Request.Params.Get("txtInfo" + j + "To" + i++);
                    if (city != "Select")
                    {
                        obj.City = city;
                    }
                    else
                    {
                        obj.City = "";
                    }
                    dbobj1.SelectQuery("select state,country from beat_master where city='" + city + "'", ref rdr1);
                    if (rdr1.Read())
                    {
                        obj.State   = rdr1["state"].ToString();
                        obj.Country = rdr1["country"].ToString();
                    }
                    else
                    {
                        obj.State   = "";
                        obj.Country = "";
                    }
                    rdr1.Close();
                    //obj.Op_Balance=Request.Params.Get("txtInfo"+j+"To"+i++);        //Coment by vikas 17.07.09
                    //obj.Balance_Type=Request.Params.Get("txtInfo"+j+"To"+i++);      //Coment by vikas 17.07.09

                    obj.ContactPerson = Request.Params.Get("txtInfo" + j + "To" + i++);                  //Add by vikas 17.07.09

                    obj.Tel_Off      = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.Mobile       = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.Tin_No       = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.CR_Limit     = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.CR_Days      = Request.Params.Get("txtInfo" + j + "To" + i++);
                    obj.Op_Balance   = Request.Params.Get("txtInfo" + j + "To" + i++);                  //Add by vikas 17.07.09
                    obj.Balance_Type = Request.Params.Get("txtInfo" + j + "To" + i++);                  //Add by vikas 17.07.09
                    //call the procedure ProCustomerUpdateAll for update the customer data.
                    obj.UpdateCustomerAll();
                }
                if (i > 0)
                {
                    DropSearchBy.SelectedIndex = 0;                            //Add by vikas 17.07.09
                    DropValue.Value            = "All";                        //Add by vikas 17.07.09
                    //Customer balance update after update the customer record.
                    CustomerBalanceUpdation();
                    MessageBox.Show("Customer Updated");
                }
                CreateLogFiles.ErrorLog("Form:CustomerUpdation.aspx,Method:btnSubmit_click(),  Customer Updated Successfully");
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:CustomerUpdation.aspx,Method:update().   EXCEPTION " + ex.Message);
                // CreateLogFiles.ErrorLog("Form:stockledgerUpdation.aspx,Method:update().   EXCEPTION " +ex.Message +"  User_ID : "+ Session["User_Name"].ToString());
            }
        }
コード例 #21
0
 public static long getLastId()
 {
     return(DBUtil.getLastId("conta_receber"));
 }
コード例 #22
0
ファイル: CompraDao.cs プロジェクト: LucasPMedeiros/Universo
        //--------------------------------------------------------
        public static List <Compra> BuscarTodos()
        {
            List <Compra> compras = new List <Compra>();

            try
            {
                SqlCommand cmd = new SqlCommand("select co.id, co.data, co.id_fornecedor, co.id_funcionario from compra as co ", DBUtil.getConnection());

                DBUtil.getConnection().Open();
                cmd.ExecuteNonQuery();
                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(dt);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    compras.Add(GetCompra(dt.Rows[i].ItemArray));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            finally
            {
                DBUtil.closeConnection();
            }
            return(compras);
        }
コード例 #23
0
        public static ContaReceber BuscarPorId(long id)
        {
            ContaReceber contaReceber = null;

            try
            {
                SqlCommand cmd;
                cmd = new SqlCommand("select cr.id, cr.valor, cr.data, cr.id_venda from conta_receber as cr where cr.id=@id", DBUtil.getConnection());
                DBUtil.getConnection().Open();
                cmd.Parameters.AddWithValue("@id", id);
                cmd.ExecuteNonQuery();

                DataTable dt = new DataTable();

                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(dt);

                contaReceber = getContaReceber(dt.Rows[0].ItemArray);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Erro ao buscar por id da conta a receber" + e.Message);
            }
            finally
            {
                DBUtil.closeConnection();
            }

            return(contaReceber);
        }
コード例 #24
0
 // 测试数据库连接
 private static bool checkConnect()
 {
     return(DBUtil.GetConnectionTest());
 }
コード例 #25
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region //验证
            if (Util.ControlTextIsNUll(this.s_RoleId))
            {
                MessageBox.Show("角色编号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!Util.IsContainCharNumber(this.s_RoleId, 4))
            {
                MessageBox.Show("角色编号不能大于4位!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Util.ControlTextIsNUll(this.s_RoleName))
            {
                MessageBox.Show("角色名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            InitFuncs initFuncs    = new InitFuncs();
            string    strSqlInsert = initFuncs.Build_Insert_Sql(this.panelRoles, "T_Roles");

            //插入之前首先判断是否存在该角色
            DBUtil dbUtil = new DBUtil();

            bool isExist = false;
            if (this.s_RoleId.Text.Trim() != "")
            {
                isExist = dbUtil.Is_Exist_Data("T_Roles", "RoleId", this.s_RoleId.Text.Trim());
            }

            SqlDBConnect db = new SqlDBConnect();
            if (isExist == true)
            {
                if (this.s_RoleId.ReadOnly == false)
                {
                    MessageBox.Show("已存在该角色!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                //更新
                List <string> sqls         = new List <string>();
                string        strSqlWhere  = "where RoleId='" + this.s_RoleId.Text.ToString().Trim() + "'";
                string        strSqlUpdate = initFuncs.Build_Update_Sql(this.panelRoles, "T_Roles", strSqlWhere);
                sqls.Add(strSqlUpdate);

                //更新权限
                string strRoleId = this.s_RoleId.Text.Trim();

                //先删除
                string strSqlDelete = "delete from T_Role_Rights where RoleId='{0}'";
                strSqlDelete = string.Format(strSqlDelete, strRoleId);
                sqls.Add(strSqlDelete);

                List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项
                UserPermission(this.treeViewMenus, checkedNodes);

                foreach (TreeNode treeNode in checkedNodes)
                {
                    string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')";
                    strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim());

                    sqls.Add(strSql);
                }

                db.Exec_Tansaction(sqls);

                MessageBox.Show("更新成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                InitDataGridView(this.curSelectRowIndex);
                //btnCancel_Click(null, null);
            }
            else
            {
                //插入
                string strSql_ = "select * from T_Roles where Ltrim(Rtrim(RoleName))='{0}'";
                strSql_ = string.Format(strSql_, this.s_RoleName.Text.Trim());
                if (dbUtil.yn_exist_data(strSql_))
                {
                    MessageBox.Show("该角色名已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                db.ExecuteNonQuery(strSqlInsert);

                //分配权限
                string strRoleId = this.s_RoleId.Text.Trim();
                if (strRoleId != "")
                {
                    List <string> sqls = new List <string>();

                    List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项
                    UserPermission(this.treeViewMenus, checkedNodes);

                    foreach (TreeNode treeNode in checkedNodes)
                    {
                        string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')";
                        strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim());

                        sqls.Add(strSql);
                    }

                    db.Exec_Tansaction(sqls);
                }

                MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                InitDataGridView(0);
                btnCancel_Click(null, null);
            }
        }
コード例 #26
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证
            if (this.s_ReceiptId.Text.Trim() == "")
            {
                MessageBox.Show("请输入拆件单据编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (this.comboBoxMatName.SelectedIndex == 0 || this.comboBoxMatName.Text.Trim() == "")
            {
                MessageBox.Show("请选择被拆物料!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (this.comboBoxMatType.SelectedIndex == 0 || this.comboBoxMatType.Text.Trim() == "")
            {
                MessageBox.Show("请选择被拆物料类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            #endregion

            SqlDBConnect db        = new SqlDBConnect();
            InitFuncs    initFuncs = new InitFuncs();
            DBUtil       dbUtil    = new DBUtil();
            this.s_OccurTime.Format = DateTimePickerFormat.Short;
            this.s_OccurTime.Value  = DBUtil.getServerTime();

            if (this.type == "add")
            {
                //插入之前判断
                string strSqlSel = "select * from T_MatSplit_Main where ReceiptId='{0}'";
                strSqlSel = string.Format(strSqlSel, this.s_ReceiptId.Text.Trim());
                bool isExist = dbUtil.yn_exist_data(strSqlSel);

                if (isExist)
                {
                    MessageBox.Show("已存在该拆件单据!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    List <string> sqls = new List <string>();
                    //插入拆件管理主表
                    string strSqlInsert = initFuncs.Build_Insert_Sql(this.panel1, "T_MatSplit_Main");
                    sqls.Add(strSqlInsert);

                    db.Exec_Tansaction(sqls);
                    MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理
                    this.Close();
                }
            }
            else if (this.type == "edit")
            {
                //更新
                string strWhere = "where ReceiptId='{0}'";
                strWhere = string.Format(strWhere, this.s_ReceiptId.Text.Trim());
                string strSqlUpdate = initFuncs.Build_Update_Sql(this.panel1, "T_MatSplit_Main", strWhere);
                db.ExecuteNonQuery(strSqlUpdate);

                MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理
                this.Close();
            }
        }
コード例 #27
0
 public IEnumerable <FinalProductModel> GetAllProducts()
 {
     return(DBUtil.GetProducts());
 }
コード例 #28
0
        protected void B_Guardar_Click(object sender, EventArgs e)
        {
            if (B_Guardar.Text == "Crear")
            {
                if (T_COD_COMISION.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "mant_lab1", "<script language='javascript'>alert('El Codigo de la regla no puede estar vacío');</script>", false);
                }
                else if (T_NOM_COMISION.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "mant_lab2", "<script language='javascript'>alert('El Nombre de la regla no puede estar vacío');</script>", false);
                }
                else
                {
                    // GUARDAR
                    DBUtil db      = new DBUtil();
                    string usuario = Session["user"].ToString();
                    string query   = "";

                    query += "INSERT INTO [Comision_Regla] ( ";
                    query += "COD_COMISION , ";
                    query += "NOMBRE_COMISION  ";


                    query += ") VALUES ( ";
                    query += " @COD_COMISION , ";
                    query += " @NOMBRE_COMISION ";
                    query += " );";

                    List <SPVars> vars = new List <SPVars>();
                    vars.Add(new SPVars()
                    {
                        nombre = "COD_COMISION", valor = T_COD_COMISION.Text.ToString().Trim()
                    });
                    vars.Add(new SPVars()
                    {
                        nombre = "NOMBRE_COMISION", valor = T_NOM_COMISION.Text.ToString().Trim()
                    });

                    db.Scalar2(query, vars);
                    CargarGrilla();

                    B_Guardar.Visible       = false;
                    btn_nuevo_banco.Visible = true;
                    T_COD_COMISION.Text     = String.Empty;
                    T_NOM_COMISION.Text     = String.Empty;
                    T_COD_COMISION.Enabled  = false;
                    T_NOM_COMISION.Enabled  = false;
                }
            }

            else if (B_Guardar.Text == "Modificar")
            {
                if (T_COD_COMISION.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "mant_lab3", "<script language='javascript'>alert('El Codigo de la regla no puede estar vacío');</script>", false);
                }
                else if (T_NOM_COMISION.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "mant_lab4", "<script language='javascript'>alert('El Nombre de la regla no puede estar vacío');</script>", false);
                }
                else
                {
                    // GUARDAR
                    DBUtil db      = new DBUtil();
                    string usuario = Session["user"].ToString();
                    string query   = "";

                    query += "UPDATE [Comision_Regla] SET ";
                    query += "COD_COMISION = @COD_COMISION ,";
                    query += "NOMBRE_COMISION = @NOMBRE_COMISION  ";
                    query += " WHERE ID = @ID";

                    List <SPVars> vars = new List <SPVars>();
                    vars.Add(new SPVars()
                    {
                        nombre = "COD_COMISION", valor = T_COD_COMISION.Text.ToString().Trim()
                    });
                    vars.Add(new SPVars()
                    {
                        nombre = "NOMBRE_COMISION", valor = T_NOM_COMISION.Text.ToString().Trim()
                    });
                    vars.Add(new SPVars()
                    {
                        nombre = "ID", valor = T_ID_REGLA.Text.ToString().Trim()
                    });

                    db.Scalar2(query, vars);
                    CargarGrilla();

                    B_Guardar.Visible       = false;
                    btn_nuevo_banco.Visible = true;
                    T_COD_COMISION.Text     = String.Empty;
                    T_NOM_COMISION.Text     = String.Empty;
                    T_COD_COMISION.Enabled  = false;
                    T_NOM_COMISION.Enabled  = false;
                }
            }
        }
コード例 #29
0
        public override bool Publish()
        {
            try
            {
                string exceptionFile;
                string exceptionDetail;
                string exceptionData;

                ExceptionDetailBuilder.Build(this.Exception, out exceptionDetail, out exceptionData, out exceptionFile);

                string insertCommandText = @"INSERT INTO nhea_Log([Source], [UserName], [Level], [Message], [ExceptionFile], [Exception], [ExceptionData]) 
                                                VALUES(@Source, @UserName, @Level, @Message, @ExceptionFile, @Exception, @ExceptionData)";

                using (SqlConnection sqlConnection = DBUtil.CreateConnection(ConnectionSource.Log))
                {
                    using (SqlCommand cmd = new SqlCommand(insertCommandText, sqlConnection))
                    {
                        cmd.Parameters.Clear();

                        #region BuildParameters

                        cmd.Parameters.Add(new SqlParameter("@Level", StringHelper.SplitText(this.Level.ToString(), 50)));

                        if (this.Message == null)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Message", DBNull.Value));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Message", StringHelper.SplitText(this.Message, 4000)));
                        }

                        if (Source == null)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Source", DBNull.Value));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Source", StringHelper.SplitText(Source, 255)));
                        }

                        if (UserName == null)
                        {
                            cmd.Parameters.Add(new SqlParameter("@UserName", DBNull.Value));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@UserName", StringHelper.SplitText(UserName, 255)));
                        }

                        if (!String.IsNullOrEmpty(exceptionDetail))
                        {
                            cmd.Parameters.Add(new SqlParameter("@Exception", StringHelper.SplitText(exceptionDetail, 8000)));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Exception", DBNull.Value));
                        }

                        if (!String.IsNullOrEmpty(exceptionFile))
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExceptionFile", StringHelper.SplitText(exceptionFile, 4000)));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExceptionFile", DBNull.Value));
                        }

                        if (!String.IsNullOrEmpty(exceptionData))
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExceptionData", StringHelper.SplitText(exceptionData, 4000)));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@ExceptionData", DBNull.Value));
                        }

                        #endregion

                        cmd.Connection.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                }

                return(base.Publish());
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, PublishTypes.File, null, null, ex.Message, ex, false);
                Logger.Log(LogLevel.Error, PublishTypes.File, this.Source, this.UserName, this.Message, this.Exception, false);

                return(false);
            }
        }
コード例 #30
0
ファイル: Page.cs プロジェクト: msvarovsky/PDMSCore
 public void ProcessPageInfo(DataTable dt)
 {
     Title          = DBUtil.GetString(dt.Rows[0], 1);
     url            = DBUtil.GetString(dt.Rows[0], 2);
     SideMenu.NavID = DBUtil.GetInt(dt.Rows[0], 3);
 }
コード例 #31
0
    protected void CompareCaseUser()
    {
        string Col = "";

        if (Session["ModifiedCaseToCheck"] != null)
        {
            //欲修改資料
            m = (CaseUserProfile)Session["ModifiedCaseToCheck"];
            //原資料
            c = new CaseUserProfile(m.CaseID);


            foreach (PropertyInfo prop in c.GetType().GetProperties())
            {
                string ValBefore = Convert.ToString(GetProperty(c, prop.Name));
                string ValAfter  = Convert.ToString(GetProperty(m, prop.Name));
                if (ValBefore != ValAfter)
                {
                    Col += prop.Name + ",";
                }
                //取得有變動的屬性
            }
            #region MyRegion


            //if (m.BirthDate != c.BirthDate) Col += GetPropertyName(() => c.BirthDate) + ",";
            //if (m.IdNo != c.IdNo) Col += GetPropertyName(() => c.IdNo) + ",";
            //if (m.PassportNo != c.PassportNo) Col += GetPropertyName(() => c.PassportNo) + ",";
            //if (m.ResNo != c.ResNo) Col += GetPropertyName(() => c.ResNo) + ",";
            //if (m.ChName != c.ChName) Col += GetPropertyName(() => c.ChName) + ",";
            //if (m.Gender != c.Gender) Col += GetPropertyName(() => c.Gender) + ",";
            //if (m.HouseNo != c.HouseNo) Col += GetPropertyName(() => c.HouseNo) + ",";
            //if (m.ResCounty != c.ResCounty) Col += GetPropertyName(() => c.ResCounty) + ",";
            //if (m.ResTown != c.ResTown) Col += GetPropertyName(() => c.ResTown) + ",";
            //if (m.PregWeek != c.PregWeek) Col += GetPropertyName(() => c.PregWeek) + ",";
            //if (m.BirthNum != c.BirthNum) Col += GetPropertyName(() => c.BirthNum) + ",";
            //if (m.BirthSeq != c.BirthSeq) Col += GetPropertyName(() => c.BirthSeq) + ",";
            //if (m.BirthWeight != c.BirthWeight) Col += GetPropertyName(() => c.BirthWeight) + ",";
            //if (m.BirthPlace != c.BirthPlace) Col += GetPropertyName(() => c.BirthPlace) + ",";
            //if (m.Deliver != c.Deliver) Col += GetPropertyName(() => c.Deliver) + ",";
            //if (m.DeliverOrg != c.DeliverOrg) Col += GetPropertyName(() => c.DeliverOrg) + ",";
            //if (m.MarryStatus != c.MarryStatus) Col += GetPropertyName(() => c.MarryStatus) + ",";
            //if (m.ResVillage != c.ResVillage) Col += GetPropertyName(() => c.ResVillage) + ",";
            //if (m.ResAddr != c.ResAddr) Col += GetPropertyName(() => c.ResAddr) + ",";
            //if (m.ResNei != (c.ResNei == "0" ? "" : c.ResNei)) Col += GetPropertyName(() => c.ResNei) + ",";
            //if (m.EnName != c.EnName) Col += GetPropertyName(() => c.EnName) + ",";
            //if (m.OtherNo != c.OtherNo) Col += GetPropertyName(() => c.OtherNo) + ",";
            #endregion
            //這些欄位需要上傳file


            //再去看哪些需要 uploadfile



            if (Col != "")
            {
                #region 再去看哪些需要 uploadfile
                DataTable dt = (DataTable)DBUtil.DBOp("ConnDB"
                                                      , " SELECT NiisFieldName ,  ID, FieldDiscription, FileToCheck,SystemCodeKey  FROM   C_CaseCheck_FieldCheck where NiisFieldName in (select data from dbo.fn_slip_str({0},',') ) "
                                                      , new string[] { Col }
                                                      , NSDBUtil.CmdOpType.ExecuteReaderReturnDataTable);


                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow r in dt.Rows)
                    {
                        string ViewBefore    = Convert.ToString(GetProperty(c, r["NiisFieldName"].ToString()));
                        string ViewAfter     = Convert.ToString(GetProperty(m, r["NiisFieldName"].ToString()));
                        string ValBefore     = Convert.ToString(GetProperty(c, r["NiisFieldName"].ToString()));
                        string ValAfter      = Convert.ToString(GetProperty(m, r["NiisFieldName"].ToString()));
                        string SystemCodeKey = r["SystemCodeKey"].ToString();

                        if (SystemCodeKey != "")
                        {
                            if (SystemCodeKey.Contains("County") || SystemCodeKey.Contains("Town") || SystemCodeKey.Contains("Village"))
                            {
                                ViewBefore = SystemAreaCode.GetName(Convert.ToInt32(Convert.ToString(GetProperty(c, r["NiisFieldName"].ToString()))));
                                ViewAfter  = SystemAreaCode.GetName(Convert.ToInt32(Convert.ToString(GetProperty(m, r["NiisFieldName"].ToString()))));
                            }
                            else
                            {
                                int iViewBefore = 0;
                                int.TryParse(Convert.ToString(GetProperty(c, r["NiisFieldName"].ToString())), out iViewBefore);
                                int iViewAfter = 0;
                                int.TryParse(Convert.ToString(GetProperty(m, r["NiisFieldName"].ToString())), out iViewAfter);

                                ViewBefore = SystemCode.GetName(r["SystemCodeKey"].ToString(), iViewBefore);
                                ViewAfter  = SystemCode.GetName(r["SystemCodeKey"].ToString(), iViewAfter);
                            }
                        }

                        CheckFieldVM cf = new CheckFieldVM();
                        cf.ID               = Convert.ToInt32(r["ID"]);
                        cf.FieldName        = r["NiisFieldName"].ToString();
                        cf.FieldDiscription = r["FieldDiscription"].ToString();
                        cf.ValBefore        = ValBefore;
                        cf.ValAfter         = ValAfter;
                        cf.ViewBefore       = ViewBefore;
                        cf.ViewAfter        = ViewAfter;
                        cf.FileCheck        = r["FileToCheck"].ToString();
                        CheckFieldVMList.Add(cf);
                        //變成一個list 之後好操作
                    }
                }
                #endregion
            }
        }


        if (Col == "" || CheckFieldVMList.Count == 0)
        {
            Response.Redirect("UserProfileList.aspx");
        }
    }
コード例 #32
0
        private void CollectAndSavePoints()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start(); //  开始监视代码运行时间

            #region 查询点表
            string    sqlPoints = @"select t.*,t1.数据业务地址,t1.名称 from PointAddressEntry t,PumpPointAddressDetail t1  where t.点明细ID=t1.ID 
                                     and t.版本ID in(select distinct PointAddressID  from PumpJZ x,pump x1 where PumpJZReadMode='WEB-PUMP' and (x.是否删除=0 or x.是否删除 is null) and (x1.是否删除=0 or x1.是否删除 is null));";
            DataTable dtPoints  = DBUtil.ExecuteDataTable(sqlPoints, out string errMsg);
            if (!string.IsNullOrWhiteSpace(errMsg))
            {
                TraceManagerForWeb.AppendErrMsg("查询二供点表版本失败:" + errMsg);
                return;
            }
            pointsCache = new Dictionary <int, List <Point> >();
            foreach (DataRow dr in dtPoints.Rows)
            {
                int   versionID = DataUtil.ToInt(dr["版本ID"]);
                Point point     = new Point()
                {
                    pointID           = DataUtil.ToInt(dr["ID"]),
                    versionID         = versionID,
                    name              = DataUtil.ToString(dr["名称"]),
                    dataSourceAddress = DataUtil.ToString(dr["数据源地址"]).Trim(),
                    offsetAddress     = DataUtil.ToString(dr["偏移地址"]).Trim(),
                    dbSAddress        = DataUtil.ToString(dr["数据业务地址"]).Trim(),
                    type              = Point.ToType(DataUtil.ToString(dr["数据类型"])),
                    isActive          = DataUtil.ToInt(dr["是否激活"]),
                    isWrite           = DataUtil.ToInt(dr["是否写入"]),
                    scale             = DataUtil.ToDouble(dr["倍率"])
                };
                if (pointsCache.Keys.Contains(versionID))
                {
                    pointsCache[versionID].Add(point);
                }
                else
                {
                    pointsCache.Add(versionID, new List <Point>()
                    {
                        point
                    });
                }
            }
            if (pointsCache.Keys.Count == 0)
            {
                TraceManagerForWeb.AppendWarning("机组表没有读取模式关于WEB-PUMP的点表");
                return;
            }
            #endregion

            #region 查询JZ表
            string sqlJZ = @"select CONVERT(varchar(50),t1.ID) as BASEID ,t.PName as PumpName,t1.PumpJZName , t1.PointAddressID,t1.JZCode  
                             from Pump t, PumpJZ t1 where t.ID=t1.PumpId and t1.PumpJZReadMode='WEB-PUMP' and (t.是否删除=0 or t.是否删除 is null)  and (t1.是否删除=0 or t1.是否删除 is null) ;";

            DataTable dtJZIDs = DBUtil.ExecuteDataTable(sqlJZ, out errMsg);
            if (!string.IsNullOrWhiteSpace(errMsg))
            {
                TraceManagerForWeb.AppendErrMsg("查询二供机组ID列表失败:" + errMsg);
                return;
            }
            List <PumpJZ> jzs = new List <PumpJZ>();
            foreach (DataRow dr in dtJZIDs.Rows)
            {
                int          versionID  = DataUtil.ToInt(dr["PointAddressID"]);
                List <Point> points     = pointsCache[versionID];
                Point[]      pointsCopy = ByteUtil.DeepClone <List <Point> >(points).ToArray();// 一定要深度辅助一个副本,防止引用类型
                PumpJZ       jz         = new PumpJZ()
                {
                    _ID             = DataUtil.ToString(dr["BASEID"]),
                    _PumpName       = DataUtil.ToString(dr["PumpName"]),
                    _PumpJZName     = DataUtil.ToString(dr["PumpJZName"]),
                    _PandaPumpJZID  = DataUtil.ToString(dr["JZCode"]),
                    pointsVersionID = versionID,
                    points          = pointsCopy
                };
                jzs.Add(jz);
            }
            if (jzs.Count == 0)
            {
                TraceManagerForWeb.AppendWarning("机组表没有读取模式为WEB-PUMP的有效机组");
                return;
            }
            #endregion


            #region 是否需求请求新token
            if (tokenCache == null || DateTime.Compare(DateTime.Now, DataUtil.ToDateTime(tokenCache.data.expireTime)) > 0)
            {
                tokenCache = GetToken();
            }
            if (tokenCache == null)
            {
                return;
            }
            if (DateTime.Compare(DateTime.Now, DataUtil.ToDateTime(tokenCache.data.expireTime)) > 0)
            {
                TraceManagerForWeb.AppendErrMsg("获取二供标记参数为过期标记");
                return;// 获取后还是过期秘钥
            }
            #endregion

            #region 请求二供数据并存入
            List <PandaPumpJZ> pandaJZs = GetWebPumpData();
            Collect(pandaJZs, ref jzs);
            string saveSQL = GetSavePointsSQL(jzs);
            if (string.IsNullOrWhiteSpace(saveSQL))
            {
                TraceManagerForWeb.AppendWarning(string.Format(@"采集机组数量{0}获取存入数据库SQL失败,可能原因没有在线的机组", jzs.Count));
                return;
            }
            DBUtil.ExecuteNonQuery(saveSQL, out string err);
            stopwatch.Stop();                                   //  停止监视
            TimeSpan timespan     = stopwatch.Elapsed;          //  获取当前实例测量得出的总时间
            double   milliseconds = timespan.TotalMilliseconds; //  总毫秒数

            if (!string.IsNullOrWhiteSpace(err))
            {
                TraceManagerForWeb.AppendErrMsg("更新二供实时数据失败" + ",耗时:" + milliseconds.ToString() + "毫秒," + err);
            }
            else
            {
                TraceManagerForWeb.AppendDebug("更新二供实时数据成功" + ",耗时:" + milliseconds.ToString() + "毫秒");
            }
            #endregion
        }
コード例 #33
0
ファイル: Default.aspx.cs プロジェクト: clchappy/b1031
 protected void Page_Init(object sender, EventArgs e)
 {
     db = new DBUtil();
     db.getMySqlConnection();
 }