示例#1
0
 public void bindGroups()
 {
     ds = new DataSet();
     ds = objComm.GetGroups();
     gdvGroups.DataSource = ds.Tables[0];
     gdvGroups.DataBind();
 }
示例#2
0
 public static DataSet GetDropDownListAllINV_Store()
 {
     DataSet iNV_Stores = new DataSet();
     SqlINV_StoreProvider sqlINV_StoreProvider = new SqlINV_StoreProvider();
     iNV_Stores = sqlINV_StoreProvider.GetDropDownListAllINV_Store();
     return iNV_Stores;
 }
示例#3
0
 public void bindDropDownList(DropDownList ddl, DataSet ds)
 {
     if (ds.Tables[0].Rows.Count > 0)
     {
         DataTable dt = ds.Tables[0];
         int count = dt.Rows.Count;
         int index = 0;
         while (index < count)
         {
             string str_displayYear = dt.Rows[index][2].ToString().Trim();
             string str_displayMonth = dt.Rows[index][1].ToString().Trim();
             if (str_displayMonth.Equals("10"))
                 str_displayYear = (int.Parse(str_displayYear) + 1).ToString().Trim();
             string str_display = date.getMeetingName(int.Parse(str_displayMonth)) + " " + str_displayYear;
             ddl.Items.Add(new ListItem(str_display, dt.Rows[index][0].ToString().Trim()));
             index++;
         }
         ddl.Enabled = true;
     }
     else
     {
         ddl.Items.Add(new ListItem("Not Exist", "-1"));
         ddl.Enabled = false;
     }
 }
示例#4
0
    public DataSet GetSmtpSettings()
    {
        DataSet dsSmtp = new DataSet();
        SqlConnection SqlCon = new SqlConnection(ConStr);
        try
        {
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = SqlCon;

            sqlCmd.CommandText = "sp_Get_SmtpSettings";
            sqlCmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
            sqlDa.Fill(dsSmtp);

        }
        catch (SqlException SqlEx)
        {
            objNLog.Error("SQLException : " + SqlEx.Message);
            throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Inserting SMTP Settings.", SqlEx);
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            throw new Exception("**Error occured while Inserting SMTP Settings.", ex);
        }
        finally
        {
            SqlCon.Close();

        }

        return dsSmtp;
    }
示例#5
0
 public static DataSet GetAllINV_StoresWithRelation()
 {
     DataSet iNV_Stores = new DataSet();
     SqlINV_StoreProvider sqlINV_StoreProvider = new SqlINV_StoreProvider();
     iNV_Stores = sqlINV_StoreProvider.GetAllINV_Stores();
     return iNV_Stores;
 }
示例#6
0
 public static DataSet GetHR_WorkingDaysShiftingEmployeeID(string EmployeeID)
 {
     DataSet hR_WorkingDaysShiftings = new DataSet();
     SqlHR_WorkingDaysShiftingProvider sqlHR_WorkingDaysShiftingProvider = new SqlHR_WorkingDaysShiftingProvider();
     hR_WorkingDaysShiftings = sqlHR_WorkingDaysShiftingProvider.GetHR_WorkingDaysShiftingByEmployeeID(EmployeeID);
     return hR_WorkingDaysShiftings;
 }
        /// <summary>
        /// Returns a name for the CellBoundsVariable * ServiceDimensionForCellBoundsVar
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="name"></param>
        /// <param name="boundsVariableName"></param>
        /// <returns></returns>
        private static Tuple<string, string> EnsureAddAxisCellsNames(DataSet ds, string name, string boundsVariableName)
        {
            string boundsVarName = boundsVariableName;
            if (boundsVarName == null)
            {
                boundsVarName = string.Format("{0}_bnds", name);
                if (ds.Variables.Contains(boundsVarName))
                {
                    int tryNum = 1;
                    while (ds.Variables.Contains(string.Format("{0}_bnds{1}", boundsVarName, tryNum)))
                        tryNum++;
                    boundsVarName = string.Format("{0}_bnds{1}", boundsVarName, tryNum);
                }
            }

            if (ds.Variables.Contains(boundsVarName))
                throw new ArgumentException(string.Format("The dataset is already contains a variable with a name {0}. Please specyfy another one or omit it for automatic name choice", boundsVarName));

            string sndDim = "nv";
            if (ds.Dimensions.Contains(sndDim) && ds.Dimensions[sndDim].Length != 2)
            {
                int num = 1;
                while (ds.Dimensions.Contains(string.Format("{0}{1}", sndDim, num)))
                    num++;
                sndDim = string.Format("{0}{1}", sndDim, num);
            }
            return Tuple.Create(boundsVarName, sndDim);
        }
示例#8
0
 public static DataSet GetAllHR_WorkingDaysShiftingsWithRelation()
 {
     DataSet hR_WorkingDaysShiftings = new DataSet();
     SqlHR_WorkingDaysShiftingProvider sqlHR_WorkingDaysShiftingProvider = new SqlHR_WorkingDaysShiftingProvider();
     hR_WorkingDaysShiftings = sqlHR_WorkingDaysShiftingProvider.GetAllHR_WorkingDaysShiftings();
     return hR_WorkingDaysShiftings;
 }
示例#9
0
 public static DataSet GetDropDownListAllHR_WorkingDaysShifting()
 {
     DataSet hR_WorkingDaysShiftings = new DataSet();
     SqlHR_WorkingDaysShiftingProvider sqlHR_WorkingDaysShiftingProvider = new SqlHR_WorkingDaysShiftingProvider();
     hR_WorkingDaysShiftings = sqlHR_WorkingDaysShiftingProvider.GetDropDownLisAllHR_WorkingDaysShifting();
     return hR_WorkingDaysShiftings;
 }
示例#10
0
        protected void Fill_User_Header()
        {
            DataView view = null;
            SqlConnection con;
            SqlCommand cmd = new SqlCommand();
            DataSet ds     = new DataSet();
            DataTable dt   = new DataTable();
            System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/BitOp");
            System.Configuration.ConnectionStringSettings connString;
            connString = rootWebConfig.ConnectionStrings.ConnectionStrings["BopDBConnectionString"];
            con            = new SqlConnection(connString.ToString());
            cmd.Connection = con;
            con.Open();
            string sql = @"SELECT Fecha_Desde, Inicio_Nombre, Region, Supervisor
                         FROM Criterios
                         WHERE Criterio_ID = " + @Criterio_ID;
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
            dt = ds.Tables[0];
            view = new DataView(dt);
            foreach (DataRowView row in view)
            {
                Lbl_Fecha_Desde.Text    = row["Fecha_Desde"].ToString("dd-MM-yyyy");
                Lbl_Inicio_Descrip.Text = row["Inicio_Nombre"].ToString();
                Lbl_Region.Text         = row["Region"].ToString();
                Lbl_Supervisor.Text     = row["Supervisor"].ToString();
             }

            con.Close();
        }
示例#11
0
    public static string PublishActivity(int ClubId, string ActivityContent)
    {
        // 将新增活动存入数据库,并从数据库返回信息及数据
        string connString = System.Configuration.ConfigurationManager.ConnectionStrings["CZConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(connString);
        conn.Open();
        // 存储
        string PublishDate = DateTime.Now.ToString();
        string queryString1 = "Insert Into Activity Values (" + ClubId + ",N'" + ActivityContent + "','" + PublishDate + "')";
        SqlCommand cmd = new SqlCommand(queryString1, conn);
        cmd.ExecuteNonQuery();
        // 查询最后插入的数据,就是新的数据
        string queryString2 = "Select Top 1 * From Activity Where ClubId=" + ClubId + " Order By PublishDate Desc";
        cmd = new SqlCommand(queryString2, conn);
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        adapter.Fill(ds);
        int Id = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"].ToString());
        string Content = ds.Tables[0].Rows[0]["Content"].ToString();
        string Date = ds.Tables[0].Rows[0]["PublishDate"].ToString();

        conn.Close();

        // 通过判断前后时间知是否查入成功
        if (PublishDate == Date)
        {
            return "{status:1,id:" + Id + ",content:'" + Content + "',date:'" + Date + "'}";
        }
        else
        {
            return "{status:-1}";
        }
    }
示例#12
0
    /// <summary>
    /// 生成手机密码:通过用户编号
    /// </summary>
    /// <param name="sUserNo">用户编号</param>
    /// <returns>已生成手机密码的用户的手机号</returns>
    public string GenerateSMP(string sUserNo)
    {
        Random r1 = new Random();
        int iRandomPassword;
        string sRandomPassword,SM_content,mobile_telephone,sOperCode;
        DataSet ds=new DataSet();

        //生成密码
        iRandomPassword = r1.Next(1000000);
        sRandomPassword = fu.PasswordEncode(iRandomPassword.ToString());
        ds = fu.GetOneUserByUserIndex(sUserNo);

        sOperCode = ds.Tables[0].Rows[0]["User_code"].ToString();
        mobile_telephone = ds.Tables[0].Rows[0]["mobile_telephone"].ToString();

        sSql = "UPDATE Frame_user SET SM_PWD='" + sRandomPassword + "',SMP_last_change_time=getdate()" +
                " WHERE User_code = '" + sOperCode + "'";
        sv.ExecuteSql(sSql);
        //发送密码

        string SMP_validity_period = ds.Tables[0].Rows[0]["SMP_validity_period"].ToString();
        SM_content = "欢迎您使用EBM系统!您新的手机密码是:" + iRandomPassword.ToString() + "有效时间为:" + SMP_validity_period + "小时。";
        SendSMContentByPhoneCode(mobile_telephone, SM_content);
        return mobile_telephone;
    }
示例#13
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string ID;
        SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
        mycon.Open();
        DataSet mydataset = new DataSet();
        SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Blog where UserName='******'", mycon);
        mydataadapter.Fill(mydataset, "tb_Blog");
        DataRowView rowview = mydataset.Tables["tb_Blog"].DefaultView[0];
        ID = rowview["BlogID"].ToString();

        string P_str_Com = "Insert into tb_Message(FriendName,Sex,HomePhone,MobilePhone,QQ,ICQ,Address,Birthday,Email,PostCode,BlogID,IP)"
            +" values ('"+this.txtName.Text+"','"+this.DropDownList1.SelectedValue+"','"+this.txtHphone.Text+"'"
        +",'"+this.txtMphone.Text+"','"+this.txtQQ.Text+"','"+this.txtICQ.Text+"','"+this.txtAddress.Text+"'"
        +",'"+this.txtBirthday.Text+"','"+this.txtEmail.Text+"','"+this.txtPostCode.Text+"','"+ID+"','"+Request.UserHostAddress+"')";
        SqlData da = new SqlData();
        if (!ValidateDate1(txtBirthday.Text) && !ValidateDate2(txtBirthday.Text) && !ValidateDate3(txtBirthday.Text))
        {
            Response.Write("<script language=javascript>alert('输入的日期格式有误!');location='javascript:history.go(-1)'</script>");
        }
        else
        {
            bool add = da.ExceSQL(P_str_Com);
            if (add == true)
            {
                Response.Write("<script language=javascript>alert('添加成功!');location='AddLinkMan.aspx'</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('添加失败!');location='javascript:history.go(-1)'</script>");
            }
        }
    }
示例#14
0
 public static DataSet GetDropDownListAllLIB_SubCategory(int CategoryID)
 {
     DataSet lIB_SubCategories = new DataSet();
     SqlLIB_SubCategoryProvider sqlLIB_SubCategoryProvider = new SqlLIB_SubCategoryProvider();
     lIB_SubCategories = sqlLIB_SubCategoryProvider.GetDropDownLisAllLIB_SubCategory(CategoryID);
     return lIB_SubCategories;
 }
 //  To get 'SubMenu' record of 'Active' or 'Inactive' from database by stored procedure
 public DataTable LoadActiveSubMenu(bool IsActive,int LoggedInUser, string RetMsg)
 {
     SqlConnection Conn = new SqlConnection(ConnString);
     //  'uspGetSubMenuDetails' stored procedure is used to get specific records from SubMenu table
     SqlDataAdapter DAdapter = new SqlDataAdapter("uspGetSubMenuDetails", Conn);
     DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
     DataSet DSet = new DataSet();
     try
     {
         DAdapter.SelectCommand.Parameters.AddWithValue("@IsActive", IsActive);
         DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
         DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", RetMsg);
         DAdapter.Fill(DSet, "Masters.SubMenu");
         return DSet.Tables["Masters.SubMenu"];
     }
     catch
     {
         throw;
     }
     finally
     {
         DSet.Dispose();
         DAdapter.Dispose();
         Conn.Close();
         Conn.Dispose();
     }
 }
示例#16
0
 public static DataSet CustomQuery(string sQuery)
 {
     DataSet ds = new DataSet();
     SqlDataAdapter sda = new SqlDataAdapter(sQuery, sConnection);
     sda.Fill(ds);
     return ds;
 }
示例#17
0
 public static DataSet GetAllLIB_SubCategoriesWithRelation()
 {
     DataSet lIB_SubCategories = new DataSet();
     SqlLIB_SubCategoryProvider sqlLIB_SubCategoryProvider = new SqlLIB_SubCategoryProvider();
     lIB_SubCategories = sqlLIB_SubCategoryProvider.GetAllLIB_SubCategories();
     return lIB_SubCategories;
 }
示例#18
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        string strConn = WebConfigurationManager.ConnectionStrings["dmtucaoConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConn);
        con.Open();

        SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [User] WHERE [username]='" + Session["UserName"] + "'", con);
        SqlCommandBuilder scb = new SqlCommandBuilder(da);
        DataSet ds = new DataSet();
        da.Fill(ds, "user");

        if (ds.Tables["user"].Rows.Count > 0)
        {
            ds.Tables["user"].Rows[0]["face"] = FaceUrl.Text;
            ds.Tables["user"].Rows[0]["sex"] = Sex.SelectedIndex;
            ds.Tables["user"].Rows[0]["email"] = Email.Text;
            ds.Tables["user"].Rows[0]["qq"] = QQ.Text;
            ds.Tables["user"].Rows[0]["telephone"] = PhoneNumber.Text;
            ds.Tables["user"].Rows[0]["birthday"] = Birthday.Text;
            ds.Tables["user"].Rows[0]["introduction"] = Introduction.Text;
            if (da.Update(ds, "user") == 1)
                ClientScript.RegisterStartupScript(GetType(), "成功", "<script>alert('修改成功');location.reload();</script>");
        }
        con.Close();
        con = null;
        return;
    }
    private static DataSet FindBooks(string filePath, string searchString)
    {
        searchString = searchString
            .Replace("%", "!%")
            .Replace("'", "!'")
            .Replace("\"", "!\"")
            .Replace("_", "!_")
            .ToLower();

        SQLiteConnection connection = GetConnection(filePath);

        connection.Open();
        using (connection)
        {
            DataSet dataSet = new DataSet();

            SQLiteDataAdapter adapter = new SQLiteDataAdapter(
                string.Format(
                @"SELECT BookTitle, BookAuthor FROM Books
                  WHERE LOWER(BookTitle) LIKE '%{0}%' ESCAPE '!'", searchString),
                connection);

            adapter.Fill(dataSet);
            return dataSet;
        }
    }
    public static string[] GetCompletionList(string prefixText, int count)
    {
        //連線字串
        //string connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename="
                     //+ System.Web.HttpContext.Current.Server.MapPath("~/App_Data/NorthwindChinese.mdf") + ";Integrated Security=True;User Instance=True";

        ArrayList array = new ArrayList();//儲存撈出來的字串集合

        //using (SqlConnection conn = new SqlConnection(connStr))
        using (SqlConnection conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            DataSet ds = new DataSet();
            string selectStr = @"SELECT Top (" + count + ") Account_numbers FROM Account_Order_M_View Where Account_numbers Like '" + prefixText + "%'";
            SqlDataAdapter da = new SqlDataAdapter(selectStr, conn);
            conn.Open();
            da.Fill(ds);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                array.Add(dr["Account_numbers"].ToString());
            }

        }

        return (string[])array.ToArray(typeof(string));
    }
示例#21
0
    public DataSet GetDataSet(string filepath, string excelFileExtension)
    {
        try {
            System.Data.OleDb.OleDbConnection oledbcon = null;
            string strConn = string.Empty;
            switch (excelFileExtension.Trim()) {
                case "xls":
                    oledbcon = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;MaxScanRows=0;\"");
                    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filepath + ";" + "Extended Properties=Excel 8.0;";
                    break;
                case "xlsx":
                    oledbcon = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath
                   + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1'");
                    strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath
                   + ";Extended Properties=Excel 12.0;";
                    break;
            }

            //excel
            OleDbConnection conn = new OleDbConnection(strConn);
            conn.Open();
            DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
            string sheetName = dtSheetName.Rows[0]["TABLE_NAME"].ToString();
            System.Data.OleDb.OleDbDataAdapter oledbAdaptor = new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [" + sheetName + "]", oledbcon);
            //select
            DataSet ds = new DataSet();
            oledbAdaptor.Fill(ds);
            oledbcon.Close();
            return ds;
        } catch (Exception ex) {
            throw ex;
        }
    }
示例#22
0
 public static DataSet GetDropDownListAllHR_SalaryIncrement()
 {
     DataSet hR_SalaryIncrements = new DataSet();
     SqlHR_SalaryIncrementProvider sqlHR_SalaryIncrementProvider = new SqlHR_SalaryIncrementProvider();
     hR_SalaryIncrements = sqlHR_SalaryIncrementProvider.GetDropDownListAllHR_SalaryIncrement();
     return hR_SalaryIncrements;
 }
 //---------------------------------
 protected internal DataSet getProductById(int id)
 {
     try
         {
             Open();
             DataSet dataset = new DataSet();
             SqlCommand cmd = new SqlCommand();
             cmd.Connection = DataBase;
             cmd.CommandText = "Get_FeatProduct_By_ID";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@id", SqlDbType.Int);
             //Setting values to Parameters.
             cmd.Parameters[0].Value = id;
             SqlDataAdapter adapter = new SqlDataAdapter();
             adapter.SelectCommand = cmd;
             adapter.Fill(dataset);
             cmd.Dispose();
             Close();
             return dataset;
         }
         catch (SqlException oSqlExp)
         {
             //Console.WriteLine("" + oSqlExp.Message);
             return null;
         }
         catch (Exception oEx)
         {
             //Console.WriteLine("" + oEx.Message);
             return null;
         }
 }
示例#24
0
 public static DataSet GetDropDownListAllSTD_ClassSubjectEmployee()
 {
     DataSet sTD_ClassSubjectEmployees = new DataSet();
     SqlSTD_ClassSubjectEmployeeProvider sqlSTD_ClassSubjectEmployeeProvider = new SqlSTD_ClassSubjectEmployeeProvider();
     sTD_ClassSubjectEmployees = sqlSTD_ClassSubjectEmployeeProvider.GetDropDownListAllSTD_ClassSubjectEmployee();
     return sTD_ClassSubjectEmployees;
 }
示例#25
0
 public static DataSet GetSTD_ClassSubjectByClassSubjectID(int ClassSubjectID,bool isDataset)
 {
     DataSet sTD_ClassSubjectEmployee = new DataSet();
     SqlSTD_ClassSubjectEmployeeProvider sqlSTD_ClassSubjectEmployeeProvider = new SqlSTD_ClassSubjectEmployeeProvider();
     sTD_ClassSubjectEmployee = sqlSTD_ClassSubjectEmployeeProvider.GetSTD_ClassSubjectEmployeeByClassSubjectID(ClassSubjectID,isDataset);
     return sTD_ClassSubjectEmployee;
 }
示例#26
0
 public DataSet BindGrandChild(int nid)
 {
     SqlDataAdapter da = new SqlDataAdapter("select NEWS_ID, CHANNEL_ID , USERID, TIEUDE, NGAY, STT, CAP_ID from TINTUC01_ENG where MENU_SUB = 1 and NHOM = "+nid+" order by STT", con);
     DataSet ds = new DataSet();
     da.Fill(ds);
     return ds;
 }
示例#27
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        BALLogin objloginbal = new BALLogin();
        DALLogin objlogindal = new DALLogin();

        objloginbal.UserName = Session["username"].ToString();
        objloginbal.Password = txtoldpassword.Text;

        DataSet ds = new DataSet();
        ds=objlogindal.ValidateLogin(objloginbal);

        if(ds.Tables[0].Rows.Count>0)
        {
            objloginbal.LoginId = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
            objloginbal.Password = txtnewpassword.Text;
            objlogindal.ChangePassword(objloginbal);

            Response.Write("<script>alert('Password Changed');</script>");
        }
        else
        {
            Response.Write("<script>alert('Invalid Login Details');</script>");
        
        }
    }
示例#28
0
 public static DataSet GetAllHR_SalaryIncrementsWithRelation()
 {
     DataSet hR_SalaryIncrements = new DataSet();
     SqlHR_SalaryIncrementProvider sqlHR_SalaryIncrementProvider = new SqlHR_SalaryIncrementProvider();
     hR_SalaryIncrements = sqlHR_SalaryIncrementProvider.GetAllHR_SalaryIncrements();
     return hR_SalaryIncrements;
 }
示例#29
0
 public DataSet BindChild(int stt)
 {
     SqlDataAdapter da = new SqlDataAdapter("select NEWS_ID, TIEUDE, USERID, CHANNEL_ID, MENU_SUB, NGAY, STT, CAP_ID from TINTUC01_ENG where MENU_SUB = 0 and CHANNEL_ID = "+stt+" order by STT", con);
     DataSet ds = new DataSet();
     da.Fill(ds);
     return ds;
 }
 private void Load_Friends_And_Contacts()
 {
     localhostWebService.WebService service = new localhostWebService.WebService();
     DataSet dataSet = new DataSet();
     dataSet = service.GetFriendsAndContacts(user);
     Session["DataSet"] = dataSet;
 }
示例#31
0
        //Activate This Construntor to log All To Standard output
        //public TestClass():base(true){}

        //Activate this constructor to log Failures to a log file
        //public TestClass(System.IO.TextWriter tw):base(tw, false){}


        //Activate this constructor to log All to a log file
        //public TestClass(System.IO.TextWriter tw):base(tw, true){}

        //BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

        public void run()
        {
            Exception exp   = null;
            Exception tmpEx = new Exception();

            DataSet ds = new DataSet();

            ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
            ds.Tables.Add(GHTUtils.DataProvider.CreateChildDataTable());
            ds.Relations.Add(new DataRelation("myRelation", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0]));

            DataRow drParent = ds.Tables[0].Rows[0];
            DataRow drChild  = ds.Tables[1].Rows[0];

            drParent.Delete();
            drChild.Delete();
            ds.AcceptChanges();

            try
            {
                BeginCase("RowNotInTableException - AcceptChanges");
                try
                {
                    drParent.AcceptChanges();
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            try
            {
                BeginCase("RowNotInTableException - GetChildRows");
                try
                {
                    drParent.GetChildRows("myRelation");
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            try
            {
                BeginCase("RowNotInTableException - ItemArray");
                object[] o = null;
                try
                {
                    o = drParent.ItemArray;
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            // **********	don't throw exception (should be according to MSDN)	***********************
            //		try
            //		{
            //			BeginCase("RowNotInTableException - GetParentRow");
            //			DataRow dr = null;
            //			try
            //			{
            //				dr = drChild.GetParentRow("myRelation");
            //			}
            //			catch (RowNotInTableException  ex)
            //			{
            //				tmpEx = ex;
            //			}
            //			base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
            //			tmpEx = new  Exception();
            //		}
            //		catch(Exception ex)	{exp = ex;}
            //		finally	{EndCase(exp); exp = null;}

            try
            {
                BeginCase("RowNotInTableException - GetParentRows");
                DataRow[] dr = null;
                try
                {
                    dr = drChild.GetParentRows("myRelation");
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            try
            {
                BeginCase("RowNotInTableException - RejectChanges");
                try
                {
                    drParent.RejectChanges();
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            try
            {
                BeginCase("RowNotInTableException - SetParentRow");
                try
                {
                    drChild.SetParentRow(ds.Tables[0].Rows[1]);
                }
                catch (RowNotInTableException ex)
                {
                    tmpEx = ex;
                }
                base.Compare(tmpEx.GetType(), typeof(RowNotInTableException));
                tmpEx = new  Exception();
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }
        }
示例#32
0
        /// <summary>
        /// 获取案件目录
        /// </summary>
        /// <param name="Request"></param>
        /// <param name="isAll">是否获取所有目录,false为只有已分配的</param>
        /// <param name="isChecked">是否默认选中</param>
        /// <returns></returns>
        public string GetMlTreeEx(System.Web.HttpRequest Request, bool isAll, bool isChecked)
        {
            string bmsah = HttpUtility.UrlDecode(HttpUtility.UrlDecode(Request.Form["bmsah"]));
            string parneid = Request["pid"];
            string ischecked = Request["ischecked"];
            string yjxh = Request["yjxh"] ?? "";

            string strMlWhere = " and SFSC='N'";
            string where = " and level < 3";
            string withWhere = " and FMLBH is null";
            object[] values = new object[2];
            if (!string.IsNullOrEmpty(bmsah))
            {
                strMlWhere += " and BMSAH=:BMSAH";
                values[0] = bmsah;
            }
            //判断存在父级编码
            if (!string.IsNullOrEmpty(parneid))
            {
                withWhere = " and FMLBH =:FMLBH";
                values[1] = parneid;
            }
            EDRS.BLL.YX_DZJZ_JZML bll = new EDRS.BLL.YX_DZJZ_JZML(Request);
            DataSet ds = bll.GetListByTreeEx(strMlWhere, where, withWhere, true, StringPlus.ReplaceSingle(yjxh), isAll, values);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataTable dt = ds.Tables[0].Copy();
                dt.Columns["MLBH"].ColumnName = "ID";
                dt.Columns["FMLBH"].ColumnName = "PARENTID";
                dt.Columns["MLXSMC"].ColumnName = "NAME";
                if (isChecked)
                {
                    dt.Columns["ISEXIST"].ColumnName = "ischecked";
                }
                dt.Columns.Add("icon");
                foreach (DataRow dr in dt.Rows)
                {
                    switch (int.Parse(dr["MLLX"].ToString()))
                    {
                        case 1:
                            dr["icon"] = "jicon";
                            break;
                        case 2:
                            dr["icon"] = "mlicon";
                            break;
                        case 3:
                            dr["icon"] = "yicon";
                            break;
                        case 4:
                            dr["icon"] = "wjicon";
                            break;
                    }
                    if (dr["wjxhjl"] != null && dr["wjxhjl"].ToString() != "")
                        dr["ischecked"] = 1;
                    else
                        dr["ischecked"] = DBNull.Value;
                }

                Dictionary<string, string> styleValues = new Dictionary<string, string>();
                styleValues.Add("Y", "color:blue;");
                string json = new TreeJson(dt, "ID", "NAME", "PARENTID", "", "", parneid ?? "", true, true, "SFSM", styleValues, (ischecked == "true" ? true : false)).ResultJson.ToString();

                return json;

            }
            return ReturnString.JsonToString(Prompt.error, "未找到相关目录!", null);
        }
示例#33
0
        }//Main()

        public static void TableProcessURI
        (
            ref OleDbConnection oleDbConnection,
            String selectQuery,
            String filenameHtml,
            String filenameText,
            String filenameXsd,
            String filenameXml,
            String filenameXml2,
            String filenameStylesheet
        )
        {
            DataColumn dataColumnDated   = null;
            DataColumn dataColumnKeyword = null;
            DataColumn dataColumnTitle   = null;
            DataColumn dataColumnURI     = null;
            DataSet    dataSet           = null;
            DataTable  dataTable         = null;

            String exceptionMessage = null;
            String keyword          = null;
            String title            = null;
            String uri = null;
            String xmlProcessingInstructionText = null;

            OleDbCommand oleDbCommand   = null;
            IDataAdapter oleDataAdapter = null;
            IDataReader  dataReader     = null;
            //System.IO.FileStream    fileStream                    =  null;
            TextWriter       objTextWriterHtml = null;
            TextWriter       objTextWriterText = null;
            UniqueConstraint uniqueConstraint  = null;
            Uri         objUri = null;
            XmlNode     xmlNodeDocumentType = null;
            XmlNode     xmlNodeRoot         = null;
            XmlDocument xmlDocument         = null;
            XmlProcessingInstruction xmlProcessingInstruction = null;
            XmlTextWriter            xmlTextWriter            = null;

            try
            {
                UtilityDatabase.DatabaseQuery
                (
                    DatabaseConnectionString,
                    ref exceptionMessage,
                    ref dataSet,
                    selectQuery,
                    CommandType.Text
                );

                dataSet.DataSetName         = "addresses";
                dataSet.Tables[0].TableName = "address";

                UtilityXml.WriteXml
                (
                    dataSet,
                    ref exceptionMessage,
                    ref filenameXml,
                    ref filenameStylesheet
                );
            }//try
            catch (XmlException exception)
            {
                System.Console.WriteLine("Uri: {0} | Exception: {1}", title, exception.Message);
            }//catch
            catch (Exception exception)
            {
                System.Console.WriteLine("Uri: {0} | Exception: {1}", title, exception.Message);
            }//catch
            finally
            {
            } //finally
        }     //TableProcessURI
        public DataSet GetParticipantSummary(string catNo, string activeParticips, string loggedInUser, out Int32 iErrorId)
        {
            ds = new DataSet();
            try
            {
                OpenConnection(out iErrorId, out sErrorMsg);
                orlDA   = new OracleDataAdapter();
                ErrorId = new OracleParameter();
                OracleParameter pCatNo                  = new OracleParameter();
                OracleParameter pActiveParticips        = new OracleParameter();
                OracleParameter pLoggedInUser           = new OracleParameter();
                OracleParameter pCatStatusList          = new OracleParameter();
                OracleParameter pISRCStatusList         = new OracleParameter();
                OracleParameter pCatDetails             = new OracleParameter();
                OracleParameter pParticipSummaryDetails = new OracleParameter();
                OracleParameter pOptionPeriodList       = new OracleParameter();
                OracleParameter pSellerGroupList        = new OracleParameter();
                OracleParameter pEscCodeList            = new OracleParameter();

                orlCmd             = new OracleCommand("pkg_participant_summary.p_get_particip_summary", orlConn);
                orlCmd.CommandType = System.Data.CommandType.StoredProcedure;

                pCatNo.OracleDbType = OracleDbType.Varchar2;
                pCatNo.Direction    = ParameterDirection.Input;
                pCatNo.Value        = catNo;
                orlCmd.Parameters.Add(pCatNo);

                pActiveParticips.OracleDbType = OracleDbType.Varchar2;
                pActiveParticips.Direction    = ParameterDirection.Input;
                pActiveParticips.Value        = activeParticips;
                orlCmd.Parameters.Add(pActiveParticips);

                pLoggedInUser.OracleDbType = OracleDbType.Varchar2;
                pLoggedInUser.Direction    = ParameterDirection.Input;
                pLoggedInUser.Value        = loggedInUser;
                orlCmd.Parameters.Add(pLoggedInUser);

                pCatStatusList.OracleDbType = OracleDbType.RefCursor;
                pCatStatusList.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pCatStatusList);

                pISRCStatusList.OracleDbType = OracleDbType.RefCursor;
                pISRCStatusList.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pISRCStatusList);

                pCatDetails.OracleDbType = OracleDbType.RefCursor;
                pCatDetails.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pCatDetails);

                pParticipSummaryDetails.OracleDbType = OracleDbType.RefCursor;
                pParticipSummaryDetails.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pParticipSummaryDetails);

                pOptionPeriodList.OracleDbType = OracleDbType.RefCursor;
                pOptionPeriodList.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pOptionPeriodList);

                pSellerGroupList.OracleDbType = OracleDbType.RefCursor;
                pSellerGroupList.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pSellerGroupList);

                pEscCodeList.OracleDbType = OracleDbType.RefCursor;
                pEscCodeList.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pEscCodeList);

                ErrorId.OracleDbType  = OracleDbType.Int32;
                ErrorId.Direction     = ParameterDirection.Output;
                ErrorId.ParameterName = "ErrorId";
                orlCmd.Parameters.Add(ErrorId);

                orlDA = new OracleDataAdapter(orlCmd);
                orlDA.Fill(ds);
                iErrorId = Convert.ToInt32(orlCmd.Parameters["ErrorId"].Value.ToString());
            }
            catch (Exception ex)
            {
                iErrorId = 2;
            }
            finally
            {
                CloseConnection();
            }
            return(ds);
        }
        public DataSet SaveParticipantDetails(string catNo, string catStatusCode, string isCatModified, Array participantsToAddUpdate,
                                              string activeParticips, string userCode, string userRoleId, out Int32 iErrorId)
        {
            ds = new DataSet();
            try
            {
                OpenConnection(out iErrorId, out sErrorMsg);
                orlDA   = new OracleDataAdapter();
                ErrorId = new OracleParameter();
                OracleParameter pCatNo              = new OracleParameter();
                OracleParameter pCatStatusCode      = new OracleParameter();
                OracleParameter pIsCatModified      = new OracleParameter();
                OracleParameter pAddUpdateList      = new OracleParameter();
                OracleParameter pActiveParticips    = new OracleParameter();
                OracleParameter pUserCode           = new OracleParameter();
                OracleParameter pLoggedInUserRoleId = new OracleParameter();
                OracleParameter pCatlogueData       = new OracleParameter();
                OracleParameter pParticipantsData   = new OracleParameter();

                orlCmd             = new OracleCommand("pkg_participant_summary.p_save_participant_details", orlConn);
                orlCmd.CommandType = System.Data.CommandType.StoredProcedure;

                pCatNo.OracleDbType = OracleDbType.Varchar2;
                pCatNo.Direction    = ParameterDirection.Input;
                pCatNo.Value        = catNo;
                orlCmd.Parameters.Add(pCatNo);

                pCatStatusCode.OracleDbType = OracleDbType.Varchar2;
                pCatStatusCode.Direction    = ParameterDirection.Input;
                pCatStatusCode.Value        = catStatusCode;
                orlCmd.Parameters.Add(pCatStatusCode);

                pIsCatModified.OracleDbType = OracleDbType.Varchar2;
                pIsCatModified.Direction    = ParameterDirection.Input;
                pIsCatModified.Value        = isCatModified;
                orlCmd.Parameters.Add(pIsCatModified);

                pAddUpdateList.OracleDbType   = OracleDbType.Varchar2;
                pAddUpdateList.Direction      = ParameterDirection.Input;
                pAddUpdateList.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                if (participantsToAddUpdate.Length == 0)
                {
                    pAddUpdateList.Size  = 1;
                    pAddUpdateList.Value = new OracleDecimal[1] {
                        OracleDecimal.Null
                    };
                }
                else
                {
                    pAddUpdateList.Size  = participantsToAddUpdate.Length;
                    pAddUpdateList.Value = participantsToAddUpdate;
                }
                orlCmd.Parameters.Add(pAddUpdateList);

                pActiveParticips.OracleDbType = OracleDbType.Varchar2;
                pActiveParticips.Direction    = ParameterDirection.Input;
                pActiveParticips.Value        = activeParticips;
                orlCmd.Parameters.Add(pActiveParticips);

                pUserCode.OracleDbType = OracleDbType.Varchar2;
                pUserCode.Direction    = ParameterDirection.Input;
                pUserCode.Value        = userCode;
                orlCmd.Parameters.Add(pUserCode);

                pLoggedInUserRoleId.OracleDbType = OracleDbType.Varchar2;
                pLoggedInUserRoleId.Direction    = ParameterDirection.Input;
                pLoggedInUserRoleId.Value        = userRoleId;
                orlCmd.Parameters.Add(pLoggedInUserRoleId);

                pCatlogueData.OracleDbType = OracleDbType.RefCursor;
                pCatlogueData.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pCatlogueData);

                pParticipantsData.OracleDbType = OracleDbType.RefCursor;
                pParticipantsData.Direction    = System.Data.ParameterDirection.Output;
                orlCmd.Parameters.Add(pParticipantsData);

                ErrorId.OracleDbType  = OracleDbType.Int32;
                ErrorId.Direction     = ParameterDirection.Output;
                ErrorId.ParameterName = "ErrorId";
                orlCmd.Parameters.Add(ErrorId);

                orlDA = new OracleDataAdapter(orlCmd);
                orlDA.Fill(ds);
                iErrorId = Convert.ToInt32(orlCmd.Parameters["ErrorId"].Value.ToString());
            }
            catch (Exception ex)
            {
                iErrorId = 2;
            }
            finally
            {
                CloseConnection();
            }
            return(ds);
        }
        public ActionResult ProfileEdit1(User user)
        {
            string fileName = "";
            string filePath = "";
            var file = user.File[0];
            string query = "";
            try
            {
                if (file != null && file.ContentLength > 0)
                {
                    fileName = Path.GetFileName(file.FileName);
                    filePath = Path.Combine(Server.MapPath("~/images"), fileName);
                    file.SaveAs(filePath);
                    string toSave = "~/images/" + fileName;
                    if (!string.IsNullOrEmpty(user.password))
                    {
                        if (user.password == user.confirmPassword)
                        {
                            user.password = hashing.SHA512(user.password);
                            query = "UPDATE USERS SET PASSWORD = '******', photo = '" + toSave + "', bio = '" + user.bio + "' WHERE USERNAME = '******'";
                        }
                        else
                        {
                            TempData["password"] = "******";
                            return View("~/Views/Profile/ProfileEdit.cshtml", user);
                        }
                    }
                    else
                    {
                        query = "UPDATE USERS SET photo = '" + toSave + "', bio = '" + user.bio + "' WHERE USERNAME = '******'";
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(user.password))
                    {
                        if (user.password == user.confirmPassword)
                        {
                            user.password = hashing.SHA512(user.password);
                            query = "UPDATE USERS SET PASSWORD = '******', bio = '" + user.bio + "' WHERE USERNAME = '******'";

                        }
                        else
                        {
                            TempData["password"] = "******";
                            return View("~/Views/Profile/ProfileEdit.cshtml", user);
                        }
                    }
                    else
                    {
                        query = "UPDATE USERS SET bio = '" + user.bio + "' WHERE USERNAME = '******'";
                    }
                }
            }
            catch
            {
                

            }

            DatabaseModel databaseModel = new DatabaseModel();
            databaseModel.update(query);

            DatabaseModel databaseModel1 = new DatabaseModel();
            User user1 = new User();
            query = "SELECT *FROM USERS WHERE USERID = " + (int)System.Web.HttpContext.Current.Session["Id"];
            DataSet dataSet = new DataSet();
            dataSet = databaseModel1.selectFunction(query);
            LoginModel loginModel = new LoginModel();
            loginModel.userid = Convert.ToInt32(dataSet.Tables[0].Rows[0].ItemArray[0]);
            loginModel.username = dataSet.Tables[0].Rows[0].ItemArray[1].ToString();
            loginModel.path = dataSet.Tables[0].Rows[0].ItemArray[4].ToString();
            LoginAndBookList loginAndBookList = new LoginAndBookList();
            loginAndBookList.loginModel = loginModel;


            int id = (int)System.Web.HttpContext.Current.Session["Id"];


            return RedirectToAction("Profile", "Profile", new { id = id });


        }
示例#37
0
文件: HttpTags.cs 项目: zyuhua/devfw
        /// <summary>
        /// 显示标签列表
        /// </summary>
        private void Dispaly_TagsList(string pageContent)
        {
            string tagsHtml;

            int pageIndex;

            int.TryParse(request.QueryString["page"], out pageIndex);
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            StringBuilder sb = new StringBuilder();

            Regex reg = new Regex("\\$\\{([a-zA-Z]+)\\}");

            DataSet ds = new DataSet();

            ds.ReadXml(configPath);

            /*
             * //获取分页链接
             * for (int i = 0; i < ps.PageCount; i++)
             * {
             *  sb.Append("<a href=\"?page=").Append((i + 1).ToString()).Append("\"")
             *      .Append(i == pageIndex - 1 ? " style=\"background:white;color:black;text-decoration:none\"" : "").Append(">")
             *      .Append((i + 1).ToString()).Append("</a>");
             * }
             *
             * pagerHtml = sb.ToString();
             * sb.Remove(0, sb.Length);
             */

            if (Tags.Tags.Count > 0)
            {
                foreach (Tag tag in Tags.Tags)
                {
                    sb.Append("<tr><td class=\"center\"><input type=\"checkbox\" class=\"ck\" name=\"ck")
                    .Append(tag.Indent.ToString()).Append("\" indent=\"").Append(tag.Indent.ToString()).Append("\"/></td>")
                    .Append("<td class=\"center\">").Append(tag.Name).Append("</td><td>")
                    .Append(tag.LinkUri).Append("</td><td>")
                    .Append(tag.Description).Append("</td><td class=\"center\"><a href=\"javascript:;\" onclick=\"edit(this)\">修改</a></td></tr>");
                }
                tagsHtml = sb.ToString();
            }
            else
            {
                tagsHtml = "<tr><td colspan=\"5\" class=\"center\">暂无tags!</td></tr>";
            }

            string html = reg.Replace(pageContent, match =>
            {
                switch (match.Groups[1].Value)
                {
                default: return(null);

                case "css": return(ReturnStyleLink());

                case "tagsHtml": return(tagsHtml);

                case "pagetext": return("");
                }
            });

            response.Write(html);
        }
示例#38
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //using (SqlConnection conexao_SQL = new SqlConnection(acroni.classes.Conexao.nome_conexao))
            //{
            //    try
            //    {
            //        if (conexao_SQL.State != ConnectionState.Open)
            //            conexao_SQL.Open();
            //        String select = "SELECT imagem_teclado FROM tblTecladoCustomizado t INNER JOIN tblCliente c ON c.id_cliente = t.id_cliente AND usuario = '" + Session["usuario"] + "'";
            //        using (SqlCommand comando_sql = new SqlCommand(select, conexao_SQL))
            //        {
            //            using (SqlDataReader tabela = comando_sql.ExecuteReader())
            //            {
            //                tabela.Read();
            //                byte[] imgBytes = (byte[])tabela[0];

            //                string imgString = Convert.ToBase64String(imgBytes);
            //                imgFoto.ImageUrl = "data:image/png;base64," + imgString;

            //                conexao_SQL.Close();
            //            }
            //        }
            //        String select2 = "SELECT nickname FROM tblTecladoCustomizado t INNER JOIN tblCliente c ON c.id_cliente = t.id_cliente AND usuario = '" + Session["usuario"] + "'";
            //        if (conexao_SQL.State != ConnectionState.Open)
            //            conexao_SQL.Open();
            //        using (SqlCommand comando_sql = new SqlCommand(select2, conexao_SQL))
            //        {
            //            using (SqlDataReader tabela2 = comando_sql.ExecuteReader())
            //            {
            //                tabela2.Read();
            //                //byte[] nomeBytes = (byte[])tabela2[0];

            //                //string nomeString = Convert.ToBase64String(nomeBytes);
            //                lblNome.Text = tabela2[0].ToString();

            //                conexao_SQL.Close();
            //            }
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        conexao_SQL.Close();
            //    }
            //}

            using (SqlConnection conexao_SQL = new SqlConnection(Conexao.nome_conexao))
            {
                try
                {
                    if (!Page.IsPostBack)
                    {
                        if (conexao_SQL.State != ConnectionState.Open)
                        {
                            conexao_SQL.Open();
                        }
                        //string id = Request.QueryString["id"];
                        //String select = "SELECT * FROM tblTecladoCustomizado t INNER JOIN tblCliente c ON c.id_cliente = t.id_cliente AND usuario='" + Session["usuario"] + "' AND id_colecao = @id_colecao";
                        //String select2 = "SELECT * FROM tblTecladoCustomizado t INNER JOIN tblCliente c ON c.id_cliente = t.id_cliente AND usuario = '" + Session["usuario"] + "'";
                        //using (SqlCommand comando_SQL = new SqlCommand(select, conexao_SQL))
                        //{
                        //    comando_SQL.Parameters.Add("@id_colecao", SqlDbType.Int).Value = Int32.Parse(id);
                        //    using (SqlDataReader tabela = comando_SQL.ExecuteReader())
                        //    {
                        //        tabela.Read();
                        //        if (tabela.HasRows)
                        //        {
                        //            using (SqlDataAdapter da = new SqlDataAdapter(select2, conexao_SQL))
                        //            {
                        //                ds = new DataSet();
                        //                da.Fill(ds);
                        //                DataList1.DataSource = ds.Tables[0];
                        //                DataList1.DataBind();
                        //            }

                        //        }

                        //    }
                        //}
                        string CurrentUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                        CurrentUrl = CurrentUrl.Substring(CurrentUrl.LastIndexOf("=") + 1);
                        //string id = Request.QueryString["id"];
                        String select = "SELECT * FROM tblTecladoCustomizado t INNER JOIN tblCliente c ON c.id_cliente = t.id_cliente AND usuario='" + Session["usuario"] + "' AND id_colecao =" + CurrentUrl;

                        using (SqlDataAdapter da = new SqlDataAdapter(select, conexao_SQL))
                        {
                            //da.SelectCommand.Parameters.AddWithValue("@id_colecao", "%" + id + "%");

                            ds = new DataSet();
                            da.Fill(ds);
                            DataList1.DataSource = ds.Tables[0];
                            DataList1.DataBind();
                        }
                    }
                }
                catch (Exception ex)
                {
                    conexao_SQL.Close();
                }


                //string s = Page.Request.Url.AbsolutePath;
                //s = s.Substring(s.LastIndexOf("/") + 1);
                //string CurrentUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                //CurrentUrl = CurrentUrl.Substring(CurrentUrl.LastIndexOf("=") + 1);
                ////s = Form.Attributes["action"].ToString();
                //lblhue.Text = CurrentUrl;
            }
        }
示例#39
0
        public void StartTestAction()
        {
            Control.dateTimeCreatedXls = dataSourceReport + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".xls";
            Control.actionPath         = "";
            Control.tempNum            = 0;
            int a = 0;

            xConfiguration._xCreateExcelFile(Control.dateTimeCreatedXls);
            dsConfiguration = xConfiguration._xReadExcelFile(dataSourceConfiguration);

            for (; a < dsConfiguration.Tables[0].Rows.Count; a++)
            {
                BeforeAll(a);
                Control xControl = new Control();
                Control.insertText = "";

                //Assign last feature (Login, PremiumSimulation, etc)
                Control.lastFeatureAction = xConfiguration._xReplaceSpecialChars(dsConfiguration.Tables[0].Rows[a]["Scenario"].ToString());
                maxDataCounter            = 1;

                if (dsConfiguration.Tables[0].Rows[a]["Data"] != null && dsConfiguration.Tables[0].Rows[a]["Data"].ToString().Length > 1)
                {
                    dsData         = xConfiguration._xReadExcelFile(dsConfiguration.Tables[0].Rows[a]["Data"].ToString());
                    maxDataCounter = dsData.Tables[0].Rows.Count;
                }

                for (int d = 0; d < maxDataCounter; d++)
                {
                    Control.successFlag = 1;

                    if (d == 0)
                    {
                        //Create sheet in report
                        xConfiguration._xCreateSheetExcelFile(Control.dateTimeCreatedXls, Control.lastFeatureAction);
                        tempSheetName = Control.lastFeatureAction;
                    }
                    else
                    {
                        //Create sheet in report
                        Control.lastFeatureAction = tempSheetName + "_" + (d + 1).ToString();
                        xConfiguration._xCreateSheetExcelFile(Control.dateTimeCreatedXls, Control.lastFeatureAction);
                    }

                    //Read pathfile scenario xls
                    dsScenario = xConfiguration._xReadExcelFile(dsConfiguration.Tables[0].Rows[a]["PathFile"].ToString());

                    //Add By Ferie
                    lblScenario.Text = Control.lastFeatureAction;
                    InsertDetailScenario(Control.lastFeatureAction);

                    if (txtLoopingCount.Text == "1" && TotalDataScenario == 1)
                    {
                        lblTotalScenario.Text = (a + 1).ToString() + " / " + dsConfiguration.Tables[0].Rows.Count.ToString();
                    }
                    else if (txtLoopingCount.Text != "1" && TotalDataScenario == 1)
                    {
                        lblTotalScenario.Text = count.ToString() + " / " + ((dsConfiguration.Tables[0].Rows.Count * LoopingCount).ToString());
                    }
                    else if (txtLoopingCount.Text == "1" && TotalDataScenario > 1 || txtLoopingCount.Text != "1" && TotalDataScenario > 1)
                    {
                        lblTotalScenario.Text = count.ToString() + " / " + ((TotalDataScenario * LoopingCount).ToString());
                    }
                    Application.DoEvents();

                    for (int b = 0; b < dsScenario.Tables[0].Rows.Count; b++)
                    {
                        //Add by Ferie
                        progressBar2.Value            = b + 1;
                        progressBar2.Maximum          = dsScenario.Tables[0].Rows.Count;
                        lblStep.Text                  = dsScenario.Tables[0].Rows[b]["Action"].ToString();
                        lblTotalStep.Text             = (b + 1).ToString() + " / " + dsScenario.Tables[0].Rows.Count.ToString();
                        lblPercentageCurrentStep.Text = (Math.Round(((double)progressBar2.Value / (double)progressBar2.Maximum), 2) * 100).ToString() + "%";
                        UpdateDetailScenario(lblPercentageCurrentStep.Text, count, 2);
                        Application.DoEvents();

                        if (dsConfiguration.Tables[0].Rows[a]["Platform"].ToString().ToUpper().Equals("ANDROID"))
                        {
                            AndroidAction AndroidStart = new AndroidAction();
                            AndroidStart.StartTestAction(b, d);
                        }
                        else if (dsConfiguration.Tables[0].Rows[a]["Platform"].ToString().ToUpper().Equals("IOS"))
                        {
                            iOSAction iOSStart = new iOSAction();
                            iOSStart.StartTestAction(b, d);
                        }
                        else if (dsConfiguration.Tables[0].Rows[a]["Platform"].ToString().ToUpper().Equals("WEB"))
                        {
                            WebAction WebStart = new WebAction();
                            WebStart.StartTestAction(b, d);
                        }

                        #region b dalam
                        //if (!dsScenario.Tables[0].Columns.Contains("Skip") || (dsScenario.Tables[0].Columns.Contains("Skip") && !dsScenario.Tables[0].Rows[b]["Skip"].ToString().ToUpper().Equals("YES")))
                        //{

                        //    //Pengecekkan Looping(Compare nilai pada tiap iterasi)
                        //    if (dsScenario.Tables[0].Rows[b]["Value"] != null && dsScenario.Tables[0].Rows[b]["Value"].ToString().Length > 0 && dsScenario.Tables[0].Rows[b]["Value"].ToString()[0].Equals('$'))
                        //    {
                        //        dsScenario.Tables[0].Rows[b]["Value"] = dsData.Tables[0].Rows[d][dsScenario.Tables[0].Rows[b]["Value"].ToString().Substring(1, dsScenario.Tables[0].Rows[b]["Value"].ToString().Length - 1)];
                        //    }
                        //    if (dsScenario.Tables[0].Rows[b]["ResultExpectation"] != null && dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString().Length > 0 && dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString()[0].Equals('$'))
                        //    {
                        //        dsScenario.Tables[0].Rows[b]["ResultExpectation"] = dsData.Tables[0].Rows[d][dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString().Substring(1, dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString().Length - 1)];
                        //    }
                        //    if (dsScenario.Tables[0].Rows[b]["Key"] != null && dsScenario.Tables[0].Rows[b]["Key"].ToString().Length > 0 && dsScenario.Tables[0].Rows[b]["Key"].ToString()[0].Equals('$'))
                        //    {
                        //        dsScenario.Tables[0].Rows[b]["Key"] = dsData.Tables[0].Rows[d][dsScenario.Tables[0].Rows[b]["Key"].ToString().Substring(1, dsScenario.Tables[0].Rows[b]["Key"].ToString().Length - 1)];
                        //    }
                        //    if (dsScenario.Tables[0].Rows[b]["ResourceId"] != null && dsScenario.Tables[0].Rows[b]["ResourceId"].ToString().Length > 0 && dsScenario.Tables[0].Rows[b]["ResourceId"].ToString()[0].Equals('$'))
                        //    {
                        //        //dsScenario.Tables[0].Rows[b]["ResourceId"] = dsMasterResourceId.Tables[0].Select("Variable = " + dsScenario.Tables[0].Rows[b]["ResourceId"].ToString()).ToString();
                        //        DataRow dr = dsMasterResourceId.Tables[0].Select("Variable = '" + dsScenario.Tables[0].Rows[b]["ResourceId"].ToString() + "'")[0];
                        //        dsScenario.Tables[0].Rows[b]["ResourceId"] = dr["ResourceId"].ToString();
                        //    }

                        //    string tempChecking = "";
                        //    if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH") && dsScenario.Tables[0].Rows[b]["Class"].ToString().ToUpper() != null && dsScenario.Tables[0].Rows[b]["Class"].ToString().Length > 1)
                        //    {
                        //        tempChecking = xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, true);
                        //    }
                        //    if (!dsScenario.Tables[0].Rows[b]["Action"].ToString().ToUpper().Equals("WAIT") && !dsScenario.Tables[0].Rows[b]["Action"].ToString().ToUpper().Equals("CHECKNOTEXIST") && (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH")) && (dsScenario.Tables[0].Rows[b]["Class"].ToString().Length > 1) && !Control._xCheckBaseClass(tempChecking, waitSeconds, dsScenario.Tables[0].Rows[b]["Type"].ToString()))
                        //    {
                        //        int c, flagAlternate = 0;
                        //        dsBaseAlternateClass = xConfiguration._xReadAlternateClass(dataSourceBaseAlternateClass, dsScenario.Tables[0].Rows[b]["Class"].ToString());
                        //        if (dsBaseAlternateClass.Tables[0].Rows.Count > 0)
                        //        {
                        //            string tempClass = dsScenario.Tables[0].Rows[b]["Class"].ToString();
                        //            for (c = 0; c < dsBaseAlternateClass.Tables[0].Rows.Count; c++)
                        //            {
                        //                dsScenario.Tables[0].Rows[b]["Class"] = dsBaseAlternateClass.Tables[0].Rows[c]["AlternateClass"].ToString();
                        //                tempChecking = xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, true);
                        //                if (Control._xCheckBaseClass(tempChecking, waitSeconds, dsScenario.Tables[0].Rows[b]["Type"].ToString()))
                        //                {
                        //                    flagAlternate = 1;
                        //                    break;
                        //                }
                        //            }
                        //            if (c == dsBaseAlternateClass.Tables[0].Rows.Count && !dsScenario.Tables[0].Rows[b]["Action"].ToString().ToUpper().Equals("CHECKNOTEXIST"))
                        //            {
                        //                dsScenario.Tables[0].Rows[b]["Class"] = tempClass;
                        //                xControl._xNoClassSupported(dsScenario.Tables[0].Rows[b]["Class"].ToString());
                        //            }
                        //            else if (flagAlternate != 1 && !dsScenario.Tables[0].Rows[b]["Action"].ToString().ToUpper().Equals("CHECKNOTEXIST"))
                        //            {
                        //                xControl._xNoClassSupported(dsScenario.Tables[0].Rows[b]["Class"].ToString());
                        //            }
                        //        }
                        //        else
                        //        {
                        //            xControl._xNoClassOrElement(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //        }
                        //    }


                        //    string[] elementClass = dsScenario.Tables[0].Rows[b]["Class"].ToString().Split(Control.delimiterChar);
                        //    switch (dsScenario.Tables[0].Rows[b]["Action"].ToString().ToUpper())
                        //    {
                        //        //definition of each action by its type
                        //        case "WRITE":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xWriteByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xWriteByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            break;

                        //        case "CLICK":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xClickByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xClickByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            break;

                        //        case "SWIPE": xControl._xSwipe(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;
                        //        case "SWIPEUP": xControl._xSwipeUp(dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            break;
                        //        case "SWIPEDOWN": xControl._xSwipeDown(dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            break;
                        //        case "SWIPERIGHT": xControl._xSwipeRight(dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            break;
                        //        case "SWIPELEFT": xControl._xSwipeLeft(dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            break;

                        //        case "DATESWIPEUP": xControl._xDateSwipeUp(dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;

                        //        case "DATESWIPEDOWN": xControl._xDateSwipeDown(dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;

                        //        case "SCREENSHOT": xControl._xScreenShot(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //            break;

                        //        case "WAIT":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //                xControl._xWaitUntil(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"]), dsScenario.Tables[0].Rows[b]["Type"].ToString());
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //                xControl._xWaitUntil(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"]), dsScenario.Tables[0].Rows[b]["Type"].ToString());
                        //            break;

                        //        case "DELAY": xControl._xDelay(dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"]));
                        //            break;

                        //        case "CHECKRESULT":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xCheckResultById(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString(), elementClass[2].ToString());
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xCheckResultByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString(), elementClass[2].ToString());
                        //                break;
                        //            }
                        //            break;

                        //        case "PRESSKEYENTER": xControl._xPressKeyCode(dsScenario.Tables[0].Rows[b]["Action"].ToString(), 66);
                        //            break;

                        //        case "BUILDPATH": Control.actionPath += xControl._xComposeString(dsScenario.Tables[0].Rows[b], b);
                        //            break;

                        //        case "CHECKEXIST":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xCheckExistByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString());
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xCheckExistByXpath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false));
                        //                break;
                        //            }
                        //            break;

                        //        case "GET":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xGetByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xGetElementByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            break;

                        //        case "POST":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xPostByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xPostByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            break;

                        //        case "BACK": xControl._xBackDriver(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //            break;

                        //        case "SWIPENOTIFICATION": xControl._xSwipeNotificationBar(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //            break;

                        //        case "CHECKTOAST": xControl._xCheckToast(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString());
                        //            break;

                        //        //Forbidden only few devices supported, bad effect is disconecting adb driver to appium server.
                        //        case "NETWORK": xControl._xNetworkChange(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;

                        //        case "DELETETEXT":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xDeleteTextByElementId(dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xDeleteTextByXPath(xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Action"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //                break;
                        //            }
                        //            break;

                        //        case "COMPAREIMAGE": xControl._xScreenShot(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //            break;

                        //        case "CHECKCOLOR": xControl._xScreenShot(dsScenario.Tables[0].Rows[b]["Action"].ToString());
                        //            break;

                        //        case "ZOOM":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xZoomByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString());
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xZoomByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false));
                        //            }
                        //            break;

                        //        case "LONGCLICK":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xLongPressByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), 1000);
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xLongPressByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), 1000);
                        //            }
                        //            break;

                        //        case "SORT":
                        //            xControl._xCheckSorted(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;

                        //        case "CHECKACTIVEDIRECTORY":
                        //            xControl._xCheckUserAD(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString());
                        //            break;

                        //        case "CHECKSCREENORIENTATION":
                        //            xControl._xCheckPortrait(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString());
                        //            break;

                        //        case "RATE":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xRateByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xRateByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), Convert.ToInt32(dsScenario.Tables[0].Rows[b]["Value"].ToString()));
                        //            }
                        //            break;

                        //        case "CHECKNOTEXIST":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xCheckNotExistByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString());
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xCheckNotExistByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false));
                        //                break;
                        //            }
                        //            break;

                        //        //Add By Ferie
                        //        case "DBGET":
                        //            _xDBControl._xDBGet(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ConnectionString"].ToString(), dsScenario.Tables[0].Rows[b]["SQL"].ToString(), dsScenario.Tables[0].Rows[b]["ResultVariable"].ToString());
                        //            break;

                        //        case "DBPOST":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                _xDBControl._xDBPostByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                _xDBControl._xDBPostByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Value"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds);
                        //                break;
                        //            }
                        //            break;

                        //        case "DBEXECUTE":
                        //            _xDBControl._xDBExec(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ConnectionString"].ToString(), dsScenario.Tables[0].Rows[b]["SQL"].ToString());
                        //            break;

                        //        case "CHECKENABLED":
                        //            if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("ELEMENT"))
                        //            {
                        //                xControl._xCheckEnabledByElementId(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString(), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds, dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString());
                        //                break;
                        //            }
                        //            else if (dsScenario.Tables[0].Rows[b]["Type"].ToString().ToUpper().Equals("PATH"))
                        //            {
                        //                xControl._xCheckEnabledByXPath(dsScenario.Tables[0].Rows[b]["Action"].ToString(), xControl._xCheckBuildPath(dsScenario.Tables[0].Rows[b], b, false), dsScenario.Tables[0].Rows[b]["Type"].ToString(), waitSeconds, dsScenario.Tables[0].Rows[b]["ResultExpectation"].ToString());
                        //                break;
                        //            }
                        //            break;

                        //        default: xControl._xNoActionSupported(dsScenario.Tables[0].Rows[b]["Action"].ToString(), dsScenario.Tables[0].Rows[b]["ResourceId"].ToString());
                        //            break;
                        //    }
                        //}
                        #endregion
                    }

                    if (maxDataCounter > 1)
                    {
                        if (Control.successFlag == 1)
                        {
                            LoopResult[a, d] = LoopResult[a, d] + "Success; ";
                        }
                        else
                        {
                            LoopResult[a, d] = LoopResult[a, d] + "Failed; ";
                        }
                        xConfiguration._xUpdateDataResult(dsConfiguration.Tables[0].Rows[a]["Data"].ToString(), dsData, d, LoopResult[a, d]);
                    }

                    //Add By Ferie
                    UpdateDetailScenario(Control.successFlag.ToString(), count, 3);
                    if (totalFailed >= 0 && totalSuccess >= 0)
                    {
                        lblTotalFailed.Text  = totalFailed.ToString();
                        lblTotalSuccess.Text = totalSuccess.ToString();
                        Application.DoEvents();
                    }

                    if (txtLoopingCount.Text == "1" && TotalDataScenario > 1 || txtLoopingCount.Text != "1" && TotalDataScenario > 1)
                    {
                        progressBar1.Value   = count;
                        progressBar1.Maximum = (TotalDataScenario * LoopingCount);
                    }
                    lblPercentScenario.Text = (Math.Round(((double)progressBar1.Value / (double)progressBar1.Maximum), 2) * 100).ToString() + "%";
                    Application.DoEvents();
                    Control.myDictionary.Clear();
                }//Batas Loop "d"

                if (Control.successFlag == 1)
                {
                    Result[a] = Result[a] + "Success; ";
                }
                else
                {
                    Result[a] = Result[a] + "Failed; ";
                }
                Control.successFlag = 1;

                //Add by Ferie
                if (txtLoopingCount.Text == "1" && TotalDataScenario == 1)
                {
                    progressBar1.Value   = a + 1;
                    progressBar1.Maximum = dsConfiguration.Tables[0].Rows.Count;
                }
                else if (txtLoopingCount.Text != "1" && TotalDataScenario == 1)
                {
                    progressBar1.Value   = count;
                    progressBar1.Maximum = dsConfiguration.Tables[0].Rows.Count * LoopingCount;
                }

                lblPercentScenario.Text = (Math.Round(((double)progressBar1.Value / (double)progressBar1.Maximum), 2) * 100).ToString() + "%";
                Application.DoEvents();

                #region CSV

                /* CSV
                 *  foreach (string line in testCase)
                 *  {
                 *      string[] testCommand = line.Split(',');
                 *      switch (testCommand[1])
                 *      {
                 *          case "Write": xControl._xWriteByElementId(testCommand[4].ToString(), testCommand[5].ToString());
                 *              break;
                 *          case "Click": xControl._xClickByElementId(testCommand[4].ToString());
                 *              break;
                 *          case "Screenshot": xControl._xScreenShot();
                 *              break;
                 *      }
                 *  }
                 * //xControl._xWriteByElementId("com.aab.mobilesalesnative:id/etUser", "*****@*****.**");
                 * //xControl._xWriteByElementId("com.aab.mobilesalesnative:id/etPassword", "qwerty1234");
                 * //xControl._xClickByElementId("com.aab.mobilesalesnative:id/btnLogin");
                 * xControl._xScreenShot();
                 * xControl._xWaitUntil("//android.widget.ImageView[contains(@resource-id, 'android:id/up')]", 500);
                 * */
                #endregion

                xConfiguration._xUpdate(dataSourceConfiguration, "Scenario", dsConfiguration.Tables[0].Rows[a]["No"].ToString(), dsConfiguration.Tables[0].Rows[a]["Scenario"].ToString(), Result[a]);
                dsScenario.Clear();
            }
            dsConfiguration.Clear();
        }
        public static void GetProjectPlan(string queryString, string frmtext, OracleCommandBuilder builder, DataSet myDS, DataGridView dgv, OracleDataAdapter adapter, BindingSource bdsource, BindingNavigator bdn)
        {
            //OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//获得conn连接
            //conn.Open();
            //OracleCommand cmd = new OracleCommand(queryString, conn);
            //cmd.CommandType = System.Data.CommandType.StoredProcedure;

            //OracleParameter pram = new OracleParameter("V_CS", OracleType.Cursor);
            //pram.Direction = System.Data.ParameterDirection.Output;
            //cmd.Parameters.Add(pram);

            //cmd.Parameters.Add("formtext_in", OracleType.VarChar).Value = frmtext;
            //cmd.Parameters["formtext_in"].Direction = System.Data.ParameterDirection.Input;

            ////OracleDataAdapter adapter = new OracleDataAdapter(cmd);
            //myDS = new DataSet();
            //adapter = new OracleDataAdapter(cmd);
            //builder = new OracleCommandBuilder(adapter);
            ////adapter.FillSchema(
            //adapter.Fill(myDS);
            ////BindingSource bds = new BindingSource();
            //bdsource.DataSource = myDS.Tables[0];
            //dgv.DataSource = bdsource;
            //bdn.BindingSource = bdsource;
            ////dgv.DataSource = myDS.Tables["plantable"];
            //myDS.Dispose();
        }
示例#41
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DigiPower.Onlinecol.Standard.Model.T_Question_MDL GetModel(int QuestionID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 QuestionID,SingleProjectID,QuestionTypeCode,FileListID,Title,Description,CreateUserID,CreateUserName,CreateDate,AnswerCount,ClickCount,AttachName,AttachPath,ReadFlag,DescriptionHtml from T_Question ");
            strSql.Append(" where QuestionID=@QuestionID ");
            SqlParameter[] parameters = {
					new SqlParameter("@QuestionID", SqlDbType.Int,8)};
            parameters[0].Value = QuestionID;

            DigiPower.Onlinecol.Standard.Model.T_Question_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Question_MDL();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["QuestionID"].ToString() != "")
                {
                    model.QuestionID = int.Parse(ds.Tables[0].Rows[0]["QuestionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SingleProjectID"].ToString() != "")
                {
                    model.SingleProjectID = int.Parse(ds.Tables[0].Rows[0]["SingleProjectID"].ToString());
                }
 
                if (ds.Tables[0].Rows[0]["FileListID"].ToString() != "")
                {
                    model.FileListID = int.Parse(ds.Tables[0].Rows[0]["FileListID"].ToString());
                }
                model.QuestionTypeCode = ds.Tables[0].Rows[0]["QuestionTypeCode"].ToString();
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                if (ds.Tables[0].Rows[0]["CreateUserID"].ToString() != "")
                {
                    model.CreateUserID = int.Parse(ds.Tables[0].Rows[0]["CreateUserID"].ToString());
                }
                model.CreateUserName = ds.Tables[0].Rows[0]["CreateUserName"].ToString();
                if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AnswerCount"].ToString() != "")
                {
                    model.AnswerCount = int.Parse(ds.Tables[0].Rows[0]["AnswerCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClickCount"].ToString() != "")
                {
                    model.ClickCount = int.Parse(ds.Tables[0].Rows[0]["ClickCount"].ToString());
                }
                model.AttachName = ds.Tables[0].Rows[0]["AttachName"].ToString();
                model.AttachPath = ds.Tables[0].Rows[0]["AttachPath"].ToString();
                if (ds.Tables[0].Rows[0]["ReadFlag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["ReadFlag"].ToString() == "1") || (ds.Tables[0].Rows[0]["ReadFlag"].ToString().ToLower() == "true"))
                    {
                        model.ReadFlag = true;
                    }
                    else
                    {
                        model.ReadFlag = false;
                    }
                }

                model.DescriptionHtml = ds.Tables[0].Rows[0]["DescriptionHtml"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
 public FamilyTemplateReferencePlaneViewModel(DataSet dataSet, SQLiteConnection sQLiteConnection, User user, object application) : base(dataSet, sQLiteConnection, user, application)
 {
     InternalDataView = InternalDataSet.Tables[TableNames.FF_FamilyTemplateReferencePlanes.ToString()].DefaultView;
     RefreshCollections();
 }
    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            DAO_Assign_Doc DAO     = new DAO_Assign_Doc();
            ArrayList      lstDoc  = new ArrayList();
            ArrayList      lstDoc1 = new ArrayList();
            lstDoc = (ArrayList)Session["SelectedDocList"];
            lbAllSelectedDocuments.Items.Clear();
            int order = 0;

            string[] arrSpeciality = new string[1000];
            string[] arrNode       = new string[1000];
            int      count         = 0;

            ArrayList lstRemoved = (ArrayList)Session["RemovedDoc"];
            for (int i = 0; i < lstRemoved.Count; i++)
            {
                DAO_Assign_Doc dao = new DAO_Assign_Doc();
                dao = (DAO_Assign_Doc)lstRemoved[i];
                objBillSysDocBO.RemoveSpecialityDoc(dao.SelectedSpecialityID, txtCompanyID.Text, dao.SelectedId);
            }
            lstRemoved.Clear();
            for (int i = 0; i < lstDoc.Count; i++)
            {
                int iflag = 0;
                DAO = (DAO_Assign_Doc)lstDoc[i];
                string[] selectedNode = new string[500];
                selectedNode = hfselectedNodeinListbox.Value.Split(',');
                for (int j = 0; j < selectedNode.Length - 1; j++)
                {
                    if (!selectedNode[j].Equals("") && selectedNode[j].Split('~')[1].Equals(DAO.SelectedId) && selectedNode[j].Split('~')[0].Equals(DAO.SelectedSpecialityID))
                    {
                        objBillSysDocBO.AssignDocToSpeciality(selectedNode[j].Split('~')[1], ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, DAO.SelectedSpecialityID, txtCompanyID.Text, DAO.ORDER, true);
                        iflag = 1;
                        DAO.REQUIRED_MULTIPLE = true;
                        arrSpeciality[i]      = DAO.SelectedSpecialityID;
                        arrNode[i]            = selectedNode[j].Split('~')[1];
                        count++;
                    }
                    order = DAO.ORDER;
                }
                if (iflag == 0)
                {
                    objBillSysDocBO.AssignDocToSpeciality(DAO.SelectedId, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, DAO.SelectedSpecialityID, txtCompanyID.Text, DAO.ORDER, false);
                    DAO.REQUIRED_MULTIPLE = false;
                    arrSpeciality[i]      = DAO.SelectedSpecialityID;
                    arrNode[i]            = DAO.SelectedId;
                    count++;
                }
                lstDoc1.Add(DAO);
            }
            DataSet ds = new DataSet();

            //ds = objBillSysDocBO.GetSecialityDoc(txtCompanyID.Text, arrSpeciality[0]);
            //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            //{

            //    int flag = 0;
            //    for (int j = 0; j < count; j++)
            //    {
            //        if ((Convert.ToInt32(ds.Tables[0].Rows[i][0]) == Convert.ToInt32(arrNode[j])) && ds.Tables[0].Rows[i][1].Equals(arrSpeciality[j]))
            //        {
            //            flag = 1;
            //        }
            //    }
            //    if (flag == 0)
            //    {
            //        if (arrSpeciality[i] == null)
            //        {
            //            break;
            //        }
            //        else
            //        {
            //            objBillSysDocBO.RemoveSpecialityDoc(arrSpeciality[i], txtCompanyID.Text, arrNode[i]);
            //        }
            //    }
            //    ds = objBillSysDocBO.GetSecialityDoc(txtCompanyID.Text, arrSpeciality[i]);
            //}
            Session["SelectedDocList"] = lstDoc1;
            //lblmsg.Text = "Documents Saved Successfully!";

            lstDoc = (ArrayList)Session["SelectedDocList"];
            lbAllSelectedDocuments.Items.Clear();
            lbselect.Items.Clear();
            if (lstDoc != null)
            {
                hfselectedNodeinListbox.Value = "";
                for (int i = 0; i < lstDoc.Count; i++)
                {
                    DAO = (DAO_Assign_Doc)lstDoc[i];
                    if (DAO.REQUIRED_MULTIPLE)
                    {
                        ListItem lst = new ListItem();
                        lst.Text  = DAO.SelectedSpeciality + DAO.SelectedText;
                        lst.Value = DAO.SelectedSpecialityID + "~" + DAO.SelectedId;
                        hfselectedNodeinListbox.Value = hfselectedNodeinListbox.Value + lst.Value + ",";
                        lbselect.Items.Add(lst);
                    }
                    else
                    {
                        ListItem lst = new ListItem();
                        lst.Text  = DAO.SelectedSpeciality + DAO.SelectedText;
                        lst.Value = DAO.SelectedSpecialityID + "~" + DAO.SelectedId;
                        lbAllSelectedDocuments.Items.Add(lst);
                    }
                }
            }
            ds = objBillSysDocBO.GetAllSecialityDoc(txtCompanyID.Text);
            lstDoc.Clear();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DAO_Assign_Doc DAONew = new DAO_Assign_Doc();
                DAONew.SelectedId           = ds.Tables[0].Rows[i][0].ToString();
                DAONew.SelectedText         = objBillSysDocBO.GetFullPathOfNode(ds.Tables[0].Rows[i][0].ToString());
                DAONew.SelectedSpeciality   = objBillSysDocBO.GetSpecialityNameUsingId(ds.Tables[0].Rows[i][1].ToString());
                DAONew.SelectedSpecialityID = ds.Tables[0].Rows[i][1].ToString();
                DAONew.ORDER             = Convert.ToInt32(ds.Tables[0].Rows[i][2]);
                DAONew.REQUIRED_MULTIPLE = Convert.ToBoolean(ds.Tables[0].Rows[i][3]);
                lstDoc.Add(DAONew);
            }

            Session["SelectedDocList"] = lstDoc;
            lstRemoved.Clear();
            Session["RemovedDoc"] = lstRemoved;
            MessageControl1.PutMessage("Documents Saved Successfully!");
            MessageControl1.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            MessageControl1.Show();
            //Session["SelectedDocList"] = null;
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
示例#44
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            dsConfiguration    = xConfiguration._xReadExcelFile(dataSourceConfiguration);
            dsMasterResourceId = xConfiguration._xReadExcelFile(masterResourceId);
            dsDictionary       = xConfiguration._xReadExcelFile(dictionary);
            Result             = new string[dsConfiguration.Tables[0].Rows.Count];

            if (btnStart.Text == "START")
            {
                if (txtLoopingCount.Text == "" || txtLoopingCount.Text == "0")
                {
                    MessageBox.Show("Scenario Looping tidak boleh kosong atau nol!!!");
                }
                else
                {
                    LoopingCount = int.Parse(txtLoopingCount.Text);
                    Clear();
                    Control.successFlag = 1;
                    dt.Rows.Clear();
                    dataGridView1.DataSource = dt;
                    btnStart.Text            = "STOP";
                    //Hitung total data scenario looping
                    for (int x = 0; x < dsConfiguration.Tables[0].Rows.Count; x++)
                    {
                        if (dsConfiguration.Tables[0].Rows[x]["Data"].ToString() != "")
                        {
                            dsdataTemp         = xConfiguration._xReadExcelFile(dsConfiguration.Tables[0].Rows[x]["Data"].ToString());
                            maxDataCounterTemp = dsdataTemp.Tables[0].Rows.Count;
                            TotalDataScenario  = TotalDataScenario + maxDataCounterTemp;
                        }
                        else if (dsConfiguration.Tables[0].Rows[x]["Data"].ToString() == "")
                        {
                            TotalDataScenario = TotalDataScenario + 1;
                        }
                    }
                    LoopResult = new string[dsConfiguration.Tables[0].Rows.Count, TotalDataScenario];
                    //BeforeAll();
                    if (txtLoopingCount.Text != "" && txtLoopingCount.Text != "0" && txtLoopingCount.Text != "1")
                    {
                        for (int i = 0; i < int.Parse(txtLoopingCount.Text); i++)
                        {
                            StartTestAction();
                        }
                    }
                    else
                    {
                        StartTestAction();
                    }
                    AfterAll();
                    MessageBox.Show("Test Complete!!!");
                    Array.Clear(Result, 0, Result.Length);

                    if (TotalDataScenario > 0)
                    {
                        Array.Clear(LoopResult, 0, LoopResult.Length);
                    }
                    btnStart.Text = "START";
                }
            }
            else if (btnStart.Text == "STOP")
            {
                btnStart.Text = "START";
                Clear();
                AfterAll();
                MessageBox.Show("Test Fail!!!");
            }
        }
    void FillChildMenu(TreeNode node)
    {
        string  MenuID         = node.Value;
        DataSet ChildMenuTable = new DataSet();

        ChildMenuTable = objBillSysDocBO.GetChildNodes(Convert.ToInt32(MenuID), txtCompanyID.Text);

        dsSpecialityDoc = objBillSysDocBO.GetSecialityDoc(txtCompanyID.Text, ddlSpeciality.SelectedValue);
        if (ChildMenuTable.Tables.Count > 0)
        {
            foreach (DataRow row in ChildMenuTable.Tables[0].Rows)
            {
                TreeNode newNode = new TreeNode(row["SZ_NODE_NAME"].ToString(), row["I_NODE_ID"].ToString());
                newNode.PopulateOnDemand = false;
                newNode.SelectAction     = TreeNodeSelectAction.Expand;
                newNode.ShowCheckBox     = true;
                string str = "";
                newNode.ToolTip = node.ToolTip + ">>" + row["SZ_NODE_NAME"].ToString() + "(" + row["I_NODE_ID"].ToString() + ")";
                newNode.Value   = row["I_NODE_ID"].ToString();
                for (int i = 0; i < dsSpecialityDoc.Tables[0].Rows.Count; i++)
                {
                    if (row["I_NODE_ID"].ToString().Equals(dsSpecialityDoc.Tables[0].Rows[i][0].ToString()))
                    {
                        newNode.Checked = true;
                        string   path   = node.ToolTip;
                        string[] nodeid = new string[10];
                        nodeid = node.ValuePath.Split('/');
                        for (int j = 0; j < nodeid.Length; j++)
                        {
                            path = path.Replace("(" + nodeid[j] + ")", "");
                        }
                        hfselectedNode.Value = hfselectedNode.Value + path + ">>" + row["SZ_NODE_NAME"].ToString() + "~" + dsSpecialityDoc.Tables[0].Rows[i][1].ToString() + "~" + row["I_NODE_ID"].ToString() + ",";
                        ListItem list1 = new ListItem();
                        list1.Text  = path + ">>" + row["SZ_NODE_NAME"].ToString();
                        list1.Value = dsSpecialityDoc.Tables[0].Rows[i][1].ToString() + "~" + row["I_NODE_ID"].ToString();
                        lbSelectedDocs.Items.Insert(Convert.ToInt32(dsSpecialityDoc.Tables[0].Rows[i][2]), list1);
                        lbSelectedDocs.Items.RemoveAt(Convert.ToInt32(dsSpecialityDoc.Tables[0].Rows[i][2]) + 1);
                        hfOrder.Value = hfOrder.Value + row["I_NODE_ID"].ToString() + "~" + dsSpecialityDoc.Tables[0].Rows[i][2].ToString() + ",";
                        DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                        DAO.SelectedId           = row["I_NODE_ID"].ToString();
                        DAO.SelectedText         = path + ">>" + row["SZ_NODE_NAME"].ToString();
                        DAO.SelectedSpeciality   = ddlSpeciality.SelectedItem.Text;
                        DAO.SelectedSpecialityID = dsSpecialityDoc.Tables[0].Rows[i][1].ToString();
                        DAO.ORDER             = Convert.ToInt32(dsSpecialityDoc.Tables[0].Rows[i][2]);
                        DAO.REQUIRED_MULTIPLE = Convert.ToBoolean(dsSpecialityDoc.Tables[0].Rows[i][3]);
                        ArrayList lstDoc = new ArrayList();

                        if (Session["SelectedDocList"] == null)
                        {
                            lstDoc.Add(DAO);
                            Session["SelectedDocList"] = lstDoc;
                        }
                        else
                        {
                            lstDoc = (ArrayList)Session["SelectedDocList"];
                            Session["SelectedDocList"] = lstDoc;
                            int flag = 0;
                            for (int l = 0; l < lstDoc.Count; l++)
                            {
                                DAO_Assign_Doc DAO1 = new DAO_Assign_Doc();
                                DAO1 = (DAO_Assign_Doc)lstDoc[l];
                                if (DAO1.SelectedId.Equals(DAO.SelectedId) && DAO1.SelectedSpecialityID.Equals(DAO.SelectedSpecialityID))
                                {
                                    flag = 1;
                                    break;
                                }
                            }
                            if (flag == 0)
                            {
                                lstDoc.Add(DAO);
                            }
                        }
                        if (Session["SelectedDocList"] != null)
                        {
                            ArrayList lstDoc1 = new ArrayList();
                            lstDoc1 = (ArrayList)Session["SelectedDocList"];
                            for (int k = 0; k < lstDoc1.Count; k++)
                            {
                                DAO_Assign_Doc dao = new DAO_Assign_Doc();
                                dao = (DAO_Assign_Doc)lstDoc[k];
                                if (dao.SelectedId.Equals(row["I_NODE_ID"].ToString()) && dao.SelectedSpecialityID.Equals(ddlSpeciality.SelectedValue.ToString()))
                                {
                                    newNode.Checked = true;
                                }
                            }
                        }
                    }
                    else if (Session["SelectedDocList"] != null)
                    {
                        ArrayList lstDoc = new ArrayList();
                        lstDoc = (ArrayList)Session["SelectedDocList"];
                        for (int k = 0; k < lstDoc.Count; k++)
                        {
                            DAO_Assign_Doc dao = new DAO_Assign_Doc();
                            dao = (DAO_Assign_Doc)lstDoc[k];
                            if (dao.SelectedId.Equals(row["I_NODE_ID"].ToString()) && dao.SelectedSpecialityID.Equals(ddlSpeciality.SelectedValue.ToString()))
                            {
                                newNode.Checked = true;
                            }
                        }
                    }
                }
                node.ChildNodes.Add(newNode);
                FillChildMenu(newNode);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack == true)
        {
            try
            {
                CrmClass objcrm = new CrmClass();

                string state           = Request.Form["TxStatus"].ToString();
                string pgtxnid         = Request.Form["pgTxnNo"].ToString();
                string amount          = Request.Form["amount"].ToString();
                string marchant_txt_id = Request.Form["TxId"].ToString();
                objcrm.InsertCitrusTransactionResult(state, pgtxnid, amount, marchant_txt_id);


                if (state == "SUCCESS")
                {
                    SqlConnection LocalConn = new SqlConnection();
                    LocalConn.ConnectionString = ConfigurationManager.ConnectionStrings["TESTQUEUEConnectionString"].ToString();
                    LocalConn.Open();

                    SqlDataAdapter da;
                    DataSet        ds  = new DataSet();
                    SqlCommand     cmd = new SqlCommand();
                    cmd             = new SqlCommand("UpdateBookTaskOnlineTransactionID", LocalConn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@BookingID", SqlDbType.Int).Value             = Convert.ToInt32(marchant_txt_id);
                    cmd.Parameters.Add("@TransactionID", SqlDbType.VarChar, 50).Value = pgtxnid;
                    da = new SqlDataAdapter(cmd);
                    da.Fill(ds);

                    string contactNo = "";
                    string ClientID  = "0";
                    string Name      = "";
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            contactNo = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                            ClientID  = ds.Tables[0].Rows[0].ItemArray[1].ToString();
                            Name      = ds.Tables[0].Rows[0].ItemArray[2].ToString();
                        }
                    }
                    cmd.Dispose();
                    LocalConn.Close();


                    if (Request.QueryString["ReferMode"] == "N")
                    {
                        if (Name != "" && contactNo != "")
                        {
                            WebClient client = new WebClient();
                            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

                            string       MessagePart = Server.UrlEncode("Dear " + Name + ", Thank you for booking your task with Russsh.com You will receive your confirmation within the next 20 minutes.");
                            Stream       data        = client.OpenRead("http://enterprise.smsgupshup.com/GatewayAPI/rest?method=SendMessage&send_to=" + contactNo + "&msg=" + MessagePart + "&msg_type=TEXT&userid=2000148575&auth_scheme=plain&password=getmypeon&v=1.1&format=text");
                            StreamReader reader      = new StreamReader(data);
                            string       s           = reader.ReadToEnd();
                            Console.WriteLine(s);
                            data.Close();
                            reader.Close();
                        }
                    }
                }
            }
            catch (Exception em)
            {
            }
        }
    }
示例#47
0
        public ActionResult UploadToDB(string[] files)
        {
            //string[] timeSheetHeader = { "TatigkeitsNachweis", "MonatJahr", "Firma", "Mitarbeiter", "Kunde", "EBNummer", "AuftragsNummer", "SummeDerStunden", "SummeTage" };
            //string[] timeSheetLineHeader = { "Datum", "ArbeitsZeitVon", "ArbeitsZeitBis", "GerundetVon", "GerundetBis", "Pause", "Project", "TatigkeitEinsatzort", "StundenNetto" };
            const string providerXLS   = "Provider=Microsoft.ACE.OLEDB.12.0.;Data Source=";
            const string extensionXLS  = ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=2\"";
            const string providerXLSX  = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=";
            const string extensionXLSX = ";Extended Properties=\"Excel 12.0 Xml;HDR=NO;IMEX=2\"";
            string       companyId     = (string)Session["CompanyID"];
            int          modelId       = (int)IWSLookUp.MetaModelId.TimeSheet;
            int          daysInMonth   = 0;
            string       fullPath      = files[0].ToString();
            string       msg           = string.Empty;
            string       fileName      = fullPath.Substring(fullPath.IndexOf(@"\") + 1);

            if (fileName.Equals(null))
            {
                return(View("ImportTimeSheets"));
            }
            int    count     = 0;
            int    rowCount  = 0;
            string sheetName = "";
            //int errorAtLine = 0;
            int transId        = 0;
            int readDetailFrom = 11;

            try
            {
                string path = Path.Combine(Server.MapPath(TimeSheetsFileManagerSettings.RootFolder), fileName);

                string extension = Path.GetExtension(fileName).ToLower();

                if ((extension != ".xls") && (extension != ".xlsx"))
                {
                    msg = $"{IWSLocalResource.UnsupportedFormat} ";
                    var msgFormat = new { Description = msg };
                    return(Json(msgFormat));
                }
                string connectionString = string.Empty;

                DataTable dataTable = new DataTable();

                connectionString = providerXLS + path + extensionXLS;
                if (extension == ".xlsx")
                {
                    connectionString = providerXLSX + path + extensionXLSX;
                }

                OleDbConnection oleDBConnection = new OleDbConnection(connectionString);

                oleDBConnection.Open();
                dataTable = oleDBConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                oleDBConnection.Close();

                if (dataTable == null)
                {
                    return(null);
                }

                string[] excelSheets = new string[dataTable.Rows.Count];
                foreach (DataRow row in dataTable.Rows)
                {
                    excelSheets[count] = row["TABLE_NAME"].ToString();
                    sheetName          = excelSheets[count].Replace("\'", "");
                    #region key process

                    if (sheetName != "Daten$")
                    {
                        string  query   = $"Select * from [{excelSheets[count]}]";
                        DataSet dataSet = new DataSet();
                        using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, oleDBConnection))
                        {
                            dataAdapter.Fill(dataSet);
                        }
                        if (!(dataSet.Tables[0].Rows.Count > 0))
                        {
                            string x = $"{IWSLocalResource.GenericError}{Environment.NewLine}{IWSLocalResource.DataFormat} ";

                            var s = new { Description = x };

                            return(Json(s));
                        }
                        if (DateTime.TryParse(dataSet.Tables[0].Rows[12][1].ToString(), CultureInfo.GetCultureInfo(Thread.CurrentThread.CurrentUICulture.Name),
                                              DateTimeStyles.None, out DateTime currentDate))
                        {
                            daysInMonth = DateTime.DaysInMonth(currentDate.Year, currentDate.Month);
                        }
                        else
                        {
                            string x = $"{IWSLocalResource.GenericError}{Environment.NewLine}{IWSLocalResource.DataFormat} ";

                            var s = new { Description = x };

                            return(Json(s));
                        }

                        #region TimeSheets Header

                        string  TatigkeitsNachweis = dataSet.Tables[0].AsEnumerable().FirstOrDefault().Field <string>(0);
                        string  MonatJahr          = dataSet.Tables[0].AsEnumerable().Skip(1).FirstOrDefault().Field <string>(11);
                        string  Firma           = dataSet.Tables[0].AsEnumerable().Skip(3).FirstOrDefault().Field <string>(2);
                        string  Mitarbeiter     = dataSet.Tables[0].AsEnumerable().Skip(4).FirstOrDefault().Field <string>(2);
                        string  Kunde           = dataSet.Tables[0].AsEnumerable().Skip(5).FirstOrDefault().Field <string>(2);
                        string  EBNummer        = dataSet.Tables[0].AsEnumerable().Skip(6).FirstOrDefault().Field <string>(2);
                        string  AuftragsNummer  = dataSet.Tables[0].AsEnumerable().Skip(7).FirstOrDefault().Field <string>(2);
                        decimal SummeDerStunden = Convert.ToDecimal(dataSet.Tables[0].AsEnumerable().Skip(42).FirstOrDefault().Field <string>(11));
                        decimal SummeTage       = Convert.ToDecimal(dataSet.Tables[0].AsEnumerable().Skip(43).FirstOrDefault().Field <string>(11));

                        TimeSheet timeSheet = new TimeSheet
                        {
                            TatigkeitsNachweis = TatigkeitsNachweis,
                            MonatJahr          = MonatJahr,
                            Firma           = Firma,
                            Mitarbeiter     = Mitarbeiter,
                            Kunde           = Kunde,
                            EBNummer        = EBNummer,
                            AuftragsNummer  = AuftragsNummer,
                            SummeDerStunden = SummeDerStunden,
                            SummeTage       = SummeTage,
                            IsValidated     = false,
                            ModelId         = modelId,
                            CompanyId       = companyId
                        };

                        #endregion

                        #region TimeSheets Lines

                        List <TimeSheetLine> timeSheetLines = dataSet.Tables[0].AsEnumerable().Skip(readDetailFrom).Take(daysInMonth).
                                                              Where(x => x.Field <string>(0) != null).Select(t => new TimeSheetLine
                        {
                            Datum               = Convert.ToDateTime(t.Field <string>(1), CultureInfo.GetCultureInfo(Thread.CurrentThread.CurrentUICulture.Name)),
                            ArbeitsZeitVon      = t.Field <string>(2),
                            ArbeitsZeitBis      = t.Field <string>(3),
                            GerundetVon         = t.Field <string>(4),
                            GerundetBis         = t.Field <string>(5),
                            Pause               = t.Field <string>(6),
                            Project             = t.Field <string>(7),
                            TatigkeitEinsatzort = t.Field <string>(8),
                            Gerundet            = t.Field <string>(10),
                            StundenNetto        = t.Field <string>(11)
                        }).ToList();

                        #endregion

                        if (db.TimeSheets.Any(m => m.MonatJahr.Equals(timeSheet.MonatJahr) && m.Firma.Equals(timeSheet.Firma) &&
                                              m.Mitarbeiter.Equals(timeSheet.Mitarbeiter) && m.Kunde.Equals(timeSheet.Kunde) &&
                                              m.CompanyId.Equals(companyId)))
                        {
                            TimeSheet entity = db.TimeSheets.FirstOrDefault(n => n.MonatJahr.Equals(timeSheet.MonatJahr) && n.Firma.Equals(timeSheet.Firma) &&
                                                                            n.Mitarbeiter.Equals(timeSheet.Mitarbeiter) && n.Kunde.Equals(timeSheet.Kunde) &&
                                                                            n.CompanyId.Equals(companyId));
                            if (entity.IsValidated.Equals(false))
                            {
                                db.TimeSheets.DeleteOnSubmit(entity);
                                db.SubmitChanges(ConflictMode.FailOnFirstConflict);
                            }
                        }

                        db.TimeSheets.InsertOnSubmit(timeSheet);
                        db.SubmitChanges();
                        transId = db.TimeSheets.DefaultIfEmpty().Max(m => m == null ? 0 : m.Id);
                        count  += 1;

                        foreach (TimeSheetLine timeSheetLine in timeSheetLines)
                        {
                            timeSheetLine.TransId = transId;
                            db.TimeSheetLines.InsertOnSubmit(timeSheetLine);
                        }
                        db.SubmitChanges(ConflictMode.ContinueOnConflict);
                        int linx = timeSheetLines.Count();
                        rowCount += linx;
                    }

                    #endregion
                }
                if (rowCount > 0)
                {
                    msg = $"{rowCount} {IWSLocalResource.Imported} ";
                }
                else
                {
                    msg = $"{IWSLocalResource.ImportedNone}";
                }
                var Message = new { Description = msg };

                return(Json(Message));
            }
            catch (Exception ex)
            {
                IWSLookUp.LogException(ex);

                msg = ex.Message;
                //if (errorAtLine > 0)
                //    msg = $"{msg} {Environment.NewLine} {sheetName}: {errorAtLine + 1}";
                var Message = new { Description = msg };

                return(Json(Message));
            }
        }
    protected void btnAssign_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }

        try
        {
            if (ddlSpeciality.SelectedValue.Equals("0"))
            {
                usrMessage.PutMessage("Speciality is not selected.");
                usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_ErrorMessage);
                usrMessage.Show();
            }
            else
            {
                ArrayList lstDoc = (ArrayList)Session["SelectedDocList"];
                if (lstDoc == null)
                {
                    lstDoc = new ArrayList();
                }
                string[] Documents = new string[100];
                Documents = hfselectedNode.Value.Split(',');
                lbSelectedDocs.Items.Clear();
                ArrayList lstRemoved = new ArrayList();
                for (int i = 0; i < Documents.Length - 1; i++)
                {
                    DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                    DAO.SelectedText         = Documents[i].Split('~')[0];
                    DAO.SelectedId           = Documents[i].Split('~')[2];
                    DAO.SelectedSpeciality   = ddlSpeciality.SelectedItem.Text;
                    DAO.SelectedSpecialityID = ddlSpeciality.SelectedItem.Value;
                    DAO.ORDER = i;
                    for (int j = 0; j < lstDoc.Count; j++)
                    {
                        DAO_Assign_Doc DAO1 = new DAO_Assign_Doc();
                        DAO1 = (DAO_Assign_Doc)lstDoc[j];
                        if (DAO1.SelectedSpecialityID.Equals(DAO.SelectedSpecialityID))
                        {
                            lstDoc.Remove(DAO1);
                            lstRemoved.Add(DAO1);
                            j--;
                        }
                    }
                }
                if (Documents.Length - 1 == 0)
                {
                    for (int j = 0; j < lstDoc.Count; j++)
                    {
                        DAO_Assign_Doc DAO1 = new DAO_Assign_Doc();
                        DAO1 = (DAO_Assign_Doc)lstDoc[j];
                        if (ddlSpeciality.SelectedValue.Equals(DAO1.SelectedSpecialityID))
                        {
                            lstDoc.Remove(DAO1);
                            lstRemoved.Add(DAO1);
                            j--;
                        }
                    }
                }

                for (int i = 0; i < Documents.Length - 1; i++)
                {
                    ListItem list = new ListItem();
                    list.Text  = "";
                    list.Value = "";
                    if (!Documents[i].Split('~')[0].Equals(""))
                    {
                        lbSelectedDocs.Items.Add(list);
                    }
                }
                hfselectedNode.Value = "";

                ArrayList lstDoc1 = new ArrayList();
                DataSet   ds      = new DataSet();
                ds = objBillSysDocBO.GetAllSecialityDoc(txtCompanyID.Text);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                    DAO.SelectedId           = ds.Tables[0].Rows[i][0].ToString();
                    DAO.SelectedText         = objBillSysDocBO.GetFullPathOfNode(ds.Tables[0].Rows[i][0].ToString());
                    DAO.SelectedSpeciality   = objBillSysDocBO.GetSpecialityNameUsingId(ds.Tables[0].Rows[i][1].ToString());
                    DAO.SelectedSpecialityID = ds.Tables[0].Rows[i][1].ToString();
                    DAO.ORDER             = Convert.ToInt32(ds.Tables[0].Rows[i][2]);
                    DAO.REQUIRED_MULTIPLE = Convert.ToBoolean(ds.Tables[0].Rows[i][3]);
                    lstDoc1.Add(DAO);
                }

                for (int i = 0; i < Documents.Length - 1; i++)
                {
                    ListItem list = new ListItem();
                    if (!Documents[i].Split('~')[0].Equals(""))
                    {
                        list.Text  = Documents[i].Split('~')[0];
                        list.Value = Documents[i].Split('~')[1] + "~" + Documents[i].Split('~')[2];
                        lbSelectedDocs.Items.Insert(i, list);
                        lbSelectedDocs.Items.RemoveAt(i + 1);
                        DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                        DAO.SelectedText         = Documents[i].Split('~')[0];
                        DAO.SelectedId           = Documents[i].Split('~')[2];
                        DAO.SelectedSpeciality   = ddlSpeciality.SelectedItem.Text;
                        DAO.SelectedSpecialityID = ddlSpeciality.SelectedItem.Value;
                        DAO.ORDER = i;
                        int flag = 0;
                        for (int j = 0; j < lstDoc1.Count; j++)
                        {
                            DAO_Assign_Doc DAO1 = new DAO_Assign_Doc();
                            DAO1 = (DAO_Assign_Doc)lstDoc1[j];
                            if (DAO.SelectedSpecialityID.Equals(DAO1.SelectedSpecialityID) && DAO.SelectedId.Equals(DAO1.SelectedId))
                            {
                                DAO.REQUIRED_MULTIPLE = DAO1.REQUIRED_MULTIPLE;
                                flag = 1;
                                int ins = 0;
                                for (int k = 0; k < lstDoc.Count; k++)
                                {
                                    DAO_Assign_Doc DAODocInSession = new DAO_Assign_Doc();
                                    DAODocInSession = (DAO_Assign_Doc)lstDoc[k];
                                    if (DAO.SelectedSpecialityID.Equals(DAODocInSession.SelectedSpecialityID) && DAO.SelectedId.Equals(DAODocInSession.SelectedId))
                                    {
                                        ins = 1;
                                    }
                                    else
                                    {
                                        ins = 0;
                                    }
                                }
                                if (ins == 0)
                                {
                                    lstDoc.Add(DAO);
                                    lstRemoved.Remove(DAO);
                                    hfselectedNode.Value = hfselectedNode.Value + list.Text + "~" + list.Value + ",";
                                }
                                break;
                            }
                        }
                        if (flag == 0)
                        {
                            lstDoc.Add(DAO);
                            hfselectedNode.Value = hfselectedNode.Value + list.Text + "~" + list.Value + ",";
                        }
                    }
                }
                Session["SelectedDocList"] = lstDoc;
                Session["RemovedDoc"]      = lstRemoved;
                usrMessage.PutMessage("Documents Assigned Successfully!");
                usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
                usrMessage.Show();
                //Label3.Text = "Documents Assigned Successfully!";
            }
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
示例#49
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tc.Model.TcLinks> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);

            return(DataTableToList(ds.Tables[0]));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            tvwmenu.Attributes.Add("onclick", "OnCheckBoxCheckChanged(event)");
            btnAssign.Attributes.Add("onclick", "order()");
            txtCompanyID.Text = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID;
            if (!IsPostBack)
            {
                txtUserID.Text = ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID;

                //load speciality in the dropdownlist.
                DataSet  dsSpeciality = objSpeciality.GetSpecialityList(txtCompanyID.Text);
                ListItem list2        = new ListItem();
                list2.Text  = "---Select---";
                list2.Value = "0";
                ddlSpeciality.Items.Add(list2);
                for (int i = 0; i < dsSpeciality.Tables[0].Rows.Count; i++)
                {
                    ListItem list = new ListItem();
                    list.Text  = dsSpeciality.Tables[0].Rows[i][1].ToString();
                    list.Value = dsSpeciality.Tables[0].Rows[i][0].ToString();
                    ddlSpeciality.Items.Add(list);
                }
                hfselectedNodeinListbox.Value = "";

                //Load All the documents in the session, which are available in the database.
                DataSet ds = new DataSet();
                ds = objBillSysDocBO.GetAllSecialityDoc(txtCompanyID.Text);
                ArrayList lstDoc = new ArrayList();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                    DAO.SelectedId           = ds.Tables[0].Rows[i][0].ToString();
                    DAO.SelectedText         = objBillSysDocBO.GetFullPathOfNode(ds.Tables[0].Rows[i][0].ToString());
                    DAO.SelectedSpeciality   = objBillSysDocBO.GetSpecialityNameUsingId(ds.Tables[0].Rows[i][1].ToString());
                    DAO.SelectedSpecialityID = ds.Tables[0].Rows[i][1].ToString();
                    DAO.ORDER             = Convert.ToInt32(ds.Tables[0].Rows[i][2]);
                    DAO.REQUIRED_MULTIPLE = Convert.ToBoolean(ds.Tables[0].Rows[i][3]);
                    lstDoc.Add(DAO);
                }
                Session["SelectedDocList"] = lstDoc;
            }

            //load Listbox on the Step 1 of the wizard. if selected speciality is not '---Select---'
            if (!ddlSpeciality.SelectedValue.Equals("0"))
            {
                tvwmenu.Visible = true;
                DAO_Assign_Doc DAO    = new DAO_Assign_Doc();
                ArrayList      lstDoc = new ArrayList();
                lstDoc = (ArrayList)Session["SelectedDocList"];
                lbSelectedDocs.Items.Clear();
                if (lstDoc != null)
                {
                    for (int i = 0; i < lstDoc.Count; i++)
                    {
                        DAO = (DAO_Assign_Doc)lstDoc[i];
                        ListItem lst = new ListItem();
                        lst.Text  = DAO.SelectedText;
                        lst.Value = DAO.SelectedSpecialityID + "~" + DAO.SelectedId;
                        if (DAO.SelectedSpecialityID.Equals(ddlSpeciality.SelectedValue))
                        {
                            lbSelectedDocs.Items.Add(lst);
                        }
                    }
                }
            }
            else
            {
                //load treeview
                tvwmenu.Visible = true;
                tvwmenu.ExpandAll();
                tvwmenu.ShowExpandCollapse = true;
            }
            // Label3.Text = "";
            //lblmsg.Text = "";

            //load treeview and listbox on the step 1 of the wizard if user clicks on 'Previous' button on the step 2 of the wizard.
            if (Wizard1.ActiveStepIndex == 1)
            {
                if (Session["SelectedDocList"] != null)
                {
                    hfselectedNode.Value = "";
                    dsSpecialityDoc      = objBillSysDocBO.GetSecialityDoc(txtCompanyID.Text, ddlSpeciality.SelectedValue);
                    for (int i = 0; i < dsSpecialityDoc.Tables[0].Rows.Count; i++)
                    {
                        ListItem list = new ListItem();
                        list.Text  = "";
                        list.Value = "";
                        lbSelectedDocs.Items.Add(list);
                    }
                    //tvwmenu.PopulateNodesFromClient = true;
                    //tvwmenu.Nodes.RemoveAt(0);
                    //TreeNode node = new TreeNode("Document Manager", "0");
                    //node.PopulateOnDemand = true;
                    //tvwmenu.Nodes.Add(node);
                    //tvwmenu.ExpandAll();
                    int count = lbSelectedDocs.Items.Count;
                    for (int i = 0; i < count; i++)
                    {
                        if (lbSelectedDocs.Items[i].Value.Equals(""))
                        {
                            lbSelectedDocs.Items.RemoveAt(i);
                            i--;
                            count--;
                        }
                        else
                        {
                        }
                    }
                }
            }
            DataSet dsDoc = new DataSet();
            dsDoc = objBillSysDocBO.GetAllSecialityDoc(txtCompanyID.Text);
            lbAllAssignedDoc.Items.Clear();
            for (int i = 0; i < dsDoc.Tables[0].Rows.Count; i++)
            {
                DAO_Assign_Doc DAO = new DAO_Assign_Doc();
                DAO.SelectedId           = dsDoc.Tables[0].Rows[i][0].ToString();
                DAO.SelectedText         = objBillSysDocBO.GetFullPathOfNode(dsDoc.Tables[0].Rows[i][0].ToString());
                DAO.SelectedSpeciality   = objBillSysDocBO.GetSpecialityNameUsingId(dsDoc.Tables[0].Rows[i][1].ToString());
                DAO.SelectedSpecialityID = dsDoc.Tables[0].Rows[i][1].ToString();
                DAO.ORDER             = Convert.ToInt32(dsDoc.Tables[0].Rows[i][2]);
                DAO.REQUIRED_MULTIPLE = Convert.ToBoolean(dsDoc.Tables[0].Rows[i][3]);
                ListItem lst = new ListItem();
                lst.Text  = DAO.SelectedSpeciality.ToString() + DAO.SelectedText.ToString();
                lst.Value = DAO.SelectedId.ToString();
                lbAllAssignedDoc.Items.Add(lst);
            }
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        #region "check version readonly or not"
        string app_status = ((Bill_Sys_BillingCompanyObject)Session["APPSTATUS"]).SZ_READ_ONLY.ToString();
        if (app_status.Equals("True"))
        {
            Bill_Sys_ChangeVersion cv = new Bill_Sys_ChangeVersion(this.Page);
            cv.MakeReadOnlyPage("Bill_Sys_DocumentType.aspx");
        }
        #endregion

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
示例#51
0
        private void Form11_Load(object sender, EventArgs e)
        {
            Dictionary <string, string> ls = new Dictionary <string, string>();

            string commandString  = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=C:\\Users\\Administrator\\Desktop\\新建文件夹(1)\\201902更新三目\\广东1.17.09中成药全库.xls;" + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"";
            string commandString1 = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=C:\\Users\\Administrator\\Desktop\\新建文件夹(1)\\201902更新三目\\广东1.17.10西药全库.xls;" + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"";

            DataSet dataSet = new DataSet();
            //  创建连接到数据源的对象
            OleDbConnection command  = new OleDbConnection(commandString);
            OleDbConnection command1 = new OleDbConnection(commandString1);

            //  打开连接
            command.Open();
            //  Sql的查询命令,有关于数据库自行百度或者Google
            string           sqlex   = "select * from [中成药注册信息库$]";
            string           sqlex1  = "select * from [西药注册信息库$]";
            OleDbDataAdapter adaper  = new OleDbDataAdapter(sqlex, command);
            OleDbDataAdapter adaper1 = new OleDbDataAdapter(sqlex1, command1);

            //  用来存放数据
            dataSet = new DataSet();
            adaper.Fill(dataSet);
            //  填充DataTable数据到DataSet中
            DataTable dt = dataSet.Tables[0];

            foreach (DataRow r in dt.Rows)
            {
                ls.Add(r["药监局药品编码"].ToString(), r["中成药药品代码"].ToString());
            }

            dataSet = new DataSet();
            adaper1.Fill(dataSet);
            dt = dataSet.Tables[0];
            foreach (DataRow r in dt.Rows)
            {
                ls.Add(r["药监局药品编码"].ToString(), r["西药药品代码"].ToString());
            }

            hisDBConn hdb = new hisDBConn();
            //foreach (var l in ls)
            //{
            //    string sql = "update yk_typk2 set YBDM = '" + l.Value + "' where sbdm = '" + l.Key + "'";
            //    hdb.GetSqlCmd(sql);
            //}

            Dictionary <string, string> nls = new Dictionary <string, string>();
            string    sqln = "select * from [YK_TYPK2] where ybdm is null";
            DataTable dtn  = hdb.GetDataSet(sqln).Tables[0];

            foreach (DataRow n in dtn.Rows)
            {
                string ypxh = n["ypxh"].ToString();
                string sbdm = n["sbdm"].ToString();

                string sql = "update yk_typk2 set YBDM = '" + sbdm + "' where ypxh = '" + ypxh + "'";
                hdb.GetSqlCmd(sql);
            }

            //  释放连接的资源
            command.Close();
        }
示例#52
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <XCWeiXin.Model.wx_ucard_cardinfo> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);

            return(DataTableToList(ds.Tables[0]));
        }
示例#53
0
        public void DataSetExtendedPropertiesTest()
        {
            DataSet dataSet1 = new DataSet();
            dataSet1.ExtendedProperties.Add("DS1", "extended0");
            DataTable table = new DataTable("TABLE1");
            table.ExtendedProperties.Add("T1", "extended1");
            table.Columns.Add("C1", typeof(int));
            table.Columns.Add("C2", typeof(string));
            table.Columns[1].MaxLength = 20;
            table.Columns[0].ExtendedProperties.Add("C1Ext1", "extended2");
            table.Columns[1].ExtendedProperties.Add("C2Ext1", "extended3");
            dataSet1.Tables.Add(table);
            table.LoadDataRow(new object[] { 1, "One" }, false);
            table.LoadDataRow(new object[] { 2, "Two" }, false);
            string file = Path.Combine(Path.GetTempPath(), "schemas-test.xml");
            try
            {
                dataSet1.WriteXml(file, XmlWriteMode.WriteSchema);
            }
            catch (Exception ex)
            {
                Assert.False(true);
            }
            finally
            {
                File.Delete(file);
            }

            DataSet dataSet2 = new DataSet();
            dataSet2.ReadXml(new StringReader(
                @"<?xml version=""1.0"" standalone=""yes""?>
                <NewDataSet>
                  <xs:schema id=""NewDataSet"" xmlns=""""
                xmlns:xs=""http://www.w3.org/2001/XMLSchema""
                xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata""
                xmlns:msprop=""urn:schemas-microsoft-com:xml-msprop"">
                    <xs:element name=""NewDataSet"" msdata:IsDataSet=""true""
                msdata:UseCurrentLocale=""true"" msprop:DS1=""extended0"">
                      <xs:complexType>
                        <xs:choice minOccurs=""0"" maxOccurs=""unbounded"">
                          <xs:element name=""TABLE1"" msprop:T1=""extended1"">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name=""C1"" type=""xs:int"" minOccurs=""0""
                msprop:C1Ext1=""extended2"" />
                                <xs:element name=""C2"" type=""xs:string"" minOccurs=""0""
                msprop:C2Ext1=""extended3"" />
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:choice>
                      </xs:complexType>
                    </xs:element>
                  </xs:schema>
                  <TABLE1>
                    <C1>1</C1>
                    <C2>One</C2>
                  </TABLE1>
                  <TABLE1>
                    <C1>2</C1>
                    <C2>Two</C2>
                  </TABLE1>
                </NewDataSet>"), XmlReadMode.ReadSchema);
            Assert.Equal(dataSet1.ExtendedProperties["DS1"], dataSet2.ExtendedProperties["DS1"]);

            Assert.Equal(dataSet1.Tables[0].ExtendedProperties["T1"], dataSet2.Tables[0].ExtendedProperties["T1"]);
            Assert.Equal(dataSet1.Tables[0].Columns[0].ExtendedProperties["C1Ext1"],
                             dataSet2.Tables[0].Columns[0].ExtendedProperties["C1Ext1"]);
            Assert.Equal(dataSet1.Tables[0].Columns[1].ExtendedProperties["C2Ext1"],
                             dataSet2.Tables[0].Columns[1].ExtendedProperties["C2Ext1"]);
        }
示例#54
0
        private void readExcel(string filename)
        {
            string fsn = "";

            try
            {
                string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("~/upload/" + filename) + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\"";

                using (OleDbConnection conn = new OleDbConnection(connstring))
                {
                    conn.Open();
                    DataTable sheetsName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字
                    //for(int k=0;k<sheetsName.Rows.Count;k++)
                    //{
                    //    log.Info(sheetsName.Rows[k][2].ToString());
                    //}
                    string firstSheetName = sheetsName.Rows[0][2].ToString();                     //得到第一个sheet的名字
                    string sql            = string.Format("SELECT * FROM [{0}]", firstSheetName); //查询字符串


                    OleDbDataAdapter ada = new OleDbDataAdapter(sql, connstring);
                    DataSet          set = new DataSet();
                    ada.Fill(set);
                    DataTable dt = set.Tables[0];
                    int       i  = 0;
                    SQLHelper.DbHelperSQL.SetConnectionString("");
                    string    OrderNo = "", LotNo = "", ClientCode = "", ClientOrderNo = "", RecOrderPersonID = "", RecOrderPerson = "", RecOrderDate = "", SendOrderDate = "", OutGoodsDate = "";//产品名称、产品编号、版本、瑞麟编号、客户编号、客户代号、日期
                    ArrayList al = new ArrayList();
                    //获取表头  添加orderheader
                    if (dt != null && dt.Rows.Count >= 6)
                    {
                        OrderNo       = dt.Rows[1][2].ToString(); LotNo = dt.Rows[1][7].ToString(); ClientCode = dt.Rows[1][13].ToString();
                        ClientOrderNo = dt.Rows[2][2].ToString(); RecOrderPerson = dt.Rows[3][2].ToString(); RecOrderDate = dt.Rows[4][2].ToString(); SendOrderDate = dt.Rows[4][7].ToString(); OutGoodsDate = dt.Rows[4][11].ToString();

                        sql = "select sn from OrderHeader where OrderNo='" + OrderNo + "'";
                        log.Info(sql);
                        DataTable dtitem = SQLHelper.DbHelperSQL.ReturnDataTable(sql, 30);
                        if (dtitem == null || dtitem.Rows.Count == 0)
                        {
                            //sql = "insert into allitem(itemno,name) values('" + dt.Rows[2][4].ToString() + "','" + dt.Rows[2][2].ToString() + "')";
                            //log.Info("sqlallitem::::" + sql);
                            //al.Add(sql);

                            sql = "insert into OrderHeader(OrderNo,LotNo,ClientCode,ClientOrderNo,RecOrderPerson,RecOrderDate,SendOrderDate,OutGoodsDate,Inputer,InputerDate,IsCheck) values('" + OrderNo + "','" + LotNo + "','" + ClientCode + "','" + ClientOrderNo + "','" + RecOrderPerson + "','" + RecOrderDate.Replace(".", "-") + "','" + SendOrderDate.Replace(".", "-") + "','" + OutGoodsDate.Replace(".", "-") + "','" + User.Identity.Name + "',getdate(),0)";
                            log.Info("sqlbase::::" + sql);

                            SQLHelper.DbHelperSQL.ExecuteSql(sql, 30);
                        }
                        else
                        {
                            //产品名称、产品编号、版本、瑞麟编号、客户编号、客户代号、日期
                            sql = "update OrderHeader set LotNo='" + LotNo + "',ClientCode='" + ClientCode + "',ClientOrderNo='" + ClientOrderNo + "',RecOrderPerson='" + RecOrderPerson + "',RecOrderDate='" + RecOrderDate.Replace(".", "-") + "',SendOrderDate='" + SendOrderDate.Replace(".", "-") + "',OutGoodsDate='" + OutGoodsDate.Replace(".", "-") + "',Updater='" + User.Identity.Name + "',UpdateDate=getdate() where  OrderNo='" + OrderNo + "'";
                            log.Info("sqlbase::::" + sql);
                            SQLHelper.DbHelperSQL.ExecuteSql(sql, 30);
                        }
                        sql = "select max(sn) from OrderHeader";
                        SQLHelper.DbHelperSQL.SetConnectionString("");
                        fsn = SQLHelper.DbHelperSQL.GetSingle(sql).ToString();


                        #region orderdtl add
                        for (i = 7; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i][0].ToString() == "" || dt.Rows[i][1].ToString() == "")
                            {
                                break;
                            }
                            else
                            {
                                #region  bomdtl add

                                //料号,名称,规格,材质,表面处理或颜色,底数,类别
                                //ItemNo,Name,Spec,MaterialNo,ItemColor,AddReserve1,ClassName
                                sql    = "select top 1 * from OrderDetail where itemno='" + dt.Rows[i][1].ToString() + "' and ItemName='" + dt.Rows[i][2].ToString() + "' and OrderNo='" + OrderNo + "' ";
                                dtitem = SQLHelper.DbHelperSQL.ReturnDataTable(sql, 30);
                                if (dtitem == null || dtitem.Rows.Count == 0)
                                {
                                    //sql = "insert into allitem(itemno,name) values('" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "')";
                                    //log.Info("sqlallitem::::" + sql);
                                    //SQLHelper.DbHelperSQL.ExecuteSql(sql, 30);
                                    //bomsn,物料sn,料号,名称,规格,材质,表面处理,用量,分类
                                    sql = "insert into OrderDetail(FSN,OrderNo,ClinetNo,ItemNo,ItemName,Quantity,Demand1,Demand2,Demand3,Demand4,Demand5,Demand6,Demand7,Demand8,Demand9,Demand10,Demand11,Demand12,Remark,Inputer,InputerDate) values(" + fsn + ",'" + OrderNo + "','" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "','" + dt.Rows[i][3].ToString() + "'," + dt.Rows[i][4].ToString() + ",'" + dt.Rows[i][5].ToString() + "','" + dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "','" + dt.Rows[i][9].ToString() + "','" + dt.Rows[i][10].ToString() + "','" + dt.Rows[i][11].ToString() + "','" + dt.Rows[i][12].ToString() + "','" + dt.Rows[i][13].ToString() + "','" + dt.Rows[i][14].ToString() + "','" + dt.Rows[i][15].ToString() + "','" + dt.Rows[i][16].ToString() + "','" + dt.Rows[i][17].ToString().Replace(" ", "") + "','" + User.Identity.Name + "',getdate())";
                                    log.Info("sqldtl::::" + sql);
                                    SQLHelper.DbHelperSQL.ExecuteSql(sql, 30);
                                }
                                else
                                {
                                    sql = "update OrderDetail ClinetNo='" + dt.Rows[i][1].ToString() + "',ItemNo,ItemName,Quantity=" + dt.Rows[i][4].ToString() + ",Demand1='" + dt.Rows[i][5].ToString() + "',Demand2='" + dt.Rows[i][6].ToString() + "',Demand3='" + dt.Rows[i][7].ToString() + "',Demand4='" + dt.Rows[i][8].ToString() + "',Demand5='" + dt.Rows[i][9].ToString() + "',Demand6='" + dt.Rows[i][10].ToString() + "',Demand7='" + dt.Rows[i][11].ToString() + "',Demand8='" + dt.Rows[i][12].ToString() + "',Demand9='" + dt.Rows[i][13].ToString() + "',Demand10='" + dt.Rows[i][14].ToString() + "',Demand11='" + dt.Rows[i][15].ToString() + "',Demand12='" + dt.Rows[i][16].ToString() + "',Remark='" + dt.Rows[i][17].ToString().Replace(" ", "") + "',Updater='" + User.Identity.Name + "',UpdateDate=getdate() where itemno='" + dt.Rows[i][1].ToString() + "' and ItemName='" + dt.Rows[i][2].ToString() + "' and OrderNo='" + OrderNo + "' ";
                                    log.Info("sqldtl::::" + sql);
                                    SQLHelper.DbHelperSQL.ExecuteSql(sql, 30);
                                }
                                #endregion
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        Alert.Show("NO Data");
                    }
                }
                Alert.Show("导入成功");
            }
            catch (Exception ee)
            {
                Alert.Show("导入失败");
                log.Info(ee.ToString());
            }
            finally
            {
                BindGrid();
            }
        }
        public static void Update(Product product, string nname, string nsource, string nproductLink, string nprice, string ngroup,
                                  string nphotoLink)
        {
            var updateQuery = "";

            updateQuery += Check(product.name, nname, "name");
            updateQuery += Check(product.source, nsource, "source");
            updateQuery += Check(product.product_link, nproductLink, "product_link");
            updateQuery += Check(product.price, nprice, "price");
            updateQuery += Check(product.group, ngroup, "group");
            updateQuery += Check(product.photo_link, nphotoLink, "photo_link");
            if (updateQuery.Length > 0)
            {
                using (var con = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["database"].ConnectionString))
                {
                    con.Open();
                    updateQuery = updateQuery.TrimEnd(',', ' ');
                    //
                    var sql = new NpgsqlCommand(
                        "UPDATE dbo.\"Products\" SET " + updateQuery + " where name='" + product.name + "' and source='" + product.source + "';", con);
                    sql.Parameters.AddWithValue("@name", nname);
                    sql.Parameters.AddWithValue("@source", nsource);
                    sql.Parameters.AddWithValue("@product_link", nproductLink);
                    sql.Parameters.AddWithValue("@price", nprice);
                    sql.Parameters.AddWithValue("@group", ngroup);
                    sql.Parameters.AddWithValue("@photo_link", nphotoLink);

                    var dataAdapter = new NpgsqlDataAdapter("select * FROM dbo.\"Products\"", con)
                    {
                        UpdateCommand = sql
                    };

                    var dataSet = new DataSet();
                    dataAdapter.AcceptChangesDuringUpdate = true;
                    dataAdapter.Fill(dataSet, "dbo.\"Products\"");
                    Debug.WriteLine(sql.CommandText);
                    var dataTable = dataSet.Tables["dbo.\"Products\""];
                    //dataTable.Rows.Find(row => row[1].ToString().Equals(product.name));
                    foreach (DataRow dataRow in dataTable.Rows)
                    {
                        if (!dataRow[1].ToString().Equals(product.name))
                        {
                            continue;
                        }
                        if (ShouldUpdate(product.name, nname))
                        {
                            dataRow[1] = nname;
                        }
                        if (ShouldUpdate(product.source, nsource))
                        {
                            dataRow[2] = nname;
                        }
                        if (ShouldUpdate(product.product_link, nproductLink))
                        {
                            dataRow[5] = nname;
                        }
                        if (ShouldUpdate(product.price, nprice))
                        {
                            dataRow[3] = nname;
                        }
                        if (ShouldUpdate(product.@group, ngroup))
                        {
                            dataRow[6] = nname;
                        }
                        if (ShouldUpdate(product.photo_link, nphotoLink))
                        {
                            dataRow[4] = nname;
                        }
                        break;
                    }
                    dataAdapter.Update(dataTable);

                    dataAdapter.Dispose();
                }
            }
        }
示例#56
0
        public DbNetResult ExecuteCommand(DbNetCommand command, ref IDbNetScope scope, ExecuteType executetype)
        {
            StringBuilder sqlBulider = new StringBuilder(PARAMTER_REPLACE.Replace(command.SqlText, "@${pName} OR @${pName} IS NULL"));
            string        sql        = sqlBulider.ToString();

            foreach (Match m in FORMAT_PARAMTER_REPLACE.Matches(sql))
            {
                if (m.Success)
                {
                    var name     = m.Groups[P_NAME].Value;
                    var paramter = command.Paramters.Get(name);
                    if (paramter == null)
                    {
                        //如果本身不存在参数集合里面则跳过
                        continue;
                    }
                    string res  = val == null ? string.Empty : val.ToString();
                    var    code = string.Format(FORMAT_CODE, name);
                    sqlBulider = sqlBulider.Replace(code, res);
                }
            }
            sql             = sqlBulider.ToString();
            command.SqlText = sql;
            //封装数据库执行
            object result = null;

            scope = GetScope(scope, command);
            scope.Open();
            var           s   = scope as SQLiteDbNetScope;
            SQLiteCommand com = new SQLiteCommand(command.SqlText, s.Connection);

            if (s.Transaction != null)
            {
                com.Transaction = s.Transaction;
            }
            com.CommandTimeout = 30;
            switch (command.CommandType)
            {
            default:
            case "Text":
                com.CommandType = CommandType.Text;
                break;

            case "StoredProcedure":
                com.CommandType = CommandType.StoredProcedure;
                break;

            case "TableDirect":
                com.CommandType = CommandType.TableDirect;
                break;
            }
            foreach (var p in command.Paramters)
            {
                var sql_p = new SqlParameter(string.Format(PARAMTERFORAMT, p.Name), p.Value);
                if (p.Value == null)
                {
                    sql_p.Value = DBNull.Value;
                }
                switch (p.Direction)
                {
                case DbNetParamterDirection.Input:
                    sql_p.Direction = ParameterDirection.Input;
                    break;

                case DbNetParamterDirection.InputAndOutPut:
                    sql_p.Direction = ParameterDirection.InputOutput;
                    break;

                case DbNetParamterDirection.Output:
                    sql_p.Direction = ParameterDirection.Output;
                    break;
                }
                com.Parameters.Add(sql_p);
            }
            switch (executetype)
            {
            case ExecuteType.ExecuteDateTable:
                using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(com))
                {
                    DataSet set = new DataSet();
                    adapter.Fill(set);
                    result = set;
                }
                break;

            case ExecuteType.ExecuteNoQuery:
                result = com.ExecuteNonQuery();
                break;

            case ExecuteType.ExecuteObject:
                result = com.ExecuteScalar();
                break;
            }
            scope.Close();
            foreach (var p in command.Paramters)
            {
                string pName = string.Format(PARAMTERFORAMT, p.Name);
                if (com.Parameters[pName] != null)
                {
                    object pv = com.Parameters[pName].Value;
                    if (pv == DBNull.Value)
                    {
                        p.Value = null;
                    }
                    else
                    {
                        p.Value = com.Parameters[pName].Value;
                    }
                }
            }
            return(new DbNetResult(result));
        }
    private void loadGridData(bool bind = true)
	{
        _dtResources = MasterData.WTS_Resource_Get(includeArchive: false);


		_dtUser = UserManagement.LoadUserList(organizationId: 0, excludeDeveloper: false, loadArchived: false, userNameSearch: "");
		Page.ClientScript.RegisterArrayDeclaration("_userList", JsonConvert.SerializeObject(_dtUser, Newtonsoft.Json.Formatting.None));
        DataTable dt = null, dtTemp = null;
        DataSet ds = null;
        if (_refreshData || Session["dtMD_AllocationDS"] == null)
        {
            ds = MasterData.AllocationList_Get(includeArchive: true);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables.Contains("Allocation"))
                {
                    dt = ds.Tables["Allocation"];
                    HttpContext.Current.Session["dtMD_AllocationDS"] = ds;
                }
            }

        }
        else
        {
            ds = (DataSet) HttpContext.Current.Session["dtMD_AllocationDS"];
            if (ds.Tables.Contains("Allocation"))
            {
                dt = ds.Tables["Allocation"];
            }
        }

        if (dt != null)
		{
            // 12902 - 3:
            dtTemp = dt.DefaultView.ToTable(true, new string[] { "AllocationGroupID", "AllocationGroup", "AllocationCategoryID", "AllocationCategory" });
            dtTemp.DefaultView.RowFilter = "AllocationGroupID IS NOT NULL";

            //dtTemp = dt.DefaultView.ToTable(true, new string[] { "AllocationCategoryID", "AllocationCategory" });
            //dtTemp.DefaultView.RowFilter = "AllocationCategoryID IS NOT NULL";
            dtTemp = dtTemp.DefaultView.ToTable();

			this.DCC = dt.Columns;
			Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None));

			if (ds.Tables.Contains("Category"))
			{
				_dtCat = ds.Tables["Category"];
				Page.ClientScript.RegisterArrayDeclaration("_AllocationCategoryList", JsonConvert.SerializeObject(_dtCat, Newtonsoft.Json.Formatting.None));
			}
            //12092 - 3:
            if (ds.Tables.Contains("Group"))
            {
                _dtGroup = ds.Tables["Group"];
                Page.ClientScript.RegisterArrayDeclaration("_AllocationGroupList", JsonConvert.SerializeObject(_dtGroup, Newtonsoft.Json.Formatting.None));
            }

            ListItem item = null;
			foreach (DataRow row in dtTemp.Rows)
			{
				item = ddlQF.Items.FindByValue(row["AllocationCategoryID"].ToString());
				if (item == null)
				{
					ddlQF.Items.Add(new ListItem(row["AllocationCategory"].ToString(), row["AllocationCategoryID"].ToString()));
				}

                // 12902 - 3:
                item = ddlQFGroup.Items.FindByValue(row["AllocationGroupID"].ToString());
                if (item == null)
                {
                    ddlQFGroup.Items.Add(new ListItem(row["AllocationGroup"].ToString(), row["AllocationGroupID"].ToString()));
                }

            }

            // 12092 - 3 - Remarked out:
   //         item = ddlQF.Items.FindByValue(_qfAllocationCategoryID.ToString());
			//if (item != null)
			//{
			//	item.Selected = true;
			//}

            // 12092 - 3:
            item = ddlQFGroup.Items.FindByValue(_qfAllocationGroupID.ToString());
            if (item != null)
            {
                item.Selected = true;
            }

            InitializeColumnData(ref dt);
			dt.AcceptChanges();

            iti_Tools_Sharp.DynamicHeader head = WTSUtility.CreateGridMultiHeader(dt);
			if (head != null)
			{
				grdMD.DynamicHeader = head;
			}
		}

        // 12902 - 3:
		if (_qfAllocationGroupID != 0 && dt != null && dt.Rows.Count > 0)
		{
			dt.DefaultView.RowFilter = string.Format(" AllocationGroupID =  {0}", _qfAllocationGroupID.ToString());
			dt = dt.DefaultView.ToTable();
		}
        //if (_qfAllocationCategoryID != 0 && dt != null && dt.Rows.Count > 0)
        //{
        //    dt.DefaultView.RowFilter = string.Format(" AllocationCategoryID =  {0}", _qfAllocationCategoryID.ToString());
        //    dt = dt.DefaultView.ToTable();
        //}

        int count = dt.Rows.Count;
		count = count > 0 ? count - 1 : count; //need to subtract the empty row
		spanRowCount.InnerText = count.ToString();

        if (_export)
        {
            exportExcel(dt);
        }

        grdMD.DataSource = dt;
		if (bind) grdMD.DataBind();
	}
示例#58
0
 public void ReadComplexElementDocument()
 {
     var ds = new DataSet();
     ds.ReadXml(new StringReader(xml29));
 }
示例#59
0
 public void selectDataSet(DataSet dataSet)
 {
     ui_ComboBox_SelectDataSets.SelectedItem = null;
     ui_ComboBox_SelectDataSets.SelectedItem = dataSet;
 }
示例#60
0
        public ActionResult Login(string username, string password, Login login, Login lm, string rememberme)
        {
            lm.Username = username;
            lm.Password = password;

            bool rememberMe = true;
            if (rememberme != "on")
            {
                rememberMe = false;
            }

            FormsAuthentication.SetAuthCookie(username, rememberMe);
            HttpCookie myCookie = new HttpCookie("InspireUserCookie");
            bool IsRemember = rememberMe;
            if (true)
            {
                string errorMessage = "";
                string validityRemaining = "";

                List<SqlParameter> parameters = new List<SqlParameter>();

                parameters.Add(new SqlParameter()
                {
                    ParameterName = "@UserName",
                    SqlDbType = SqlDbType.VarChar,
                    Value = lm.Username,
                    Direction = System.Data.ParameterDirection.Input
                });
                parameters.Add(new SqlParameter()
                {
                    ParameterName = "@Password",
                    SqlDbType = SqlDbType.VarChar,
                    Value = lm.Password,
                    Direction = System.Data.ParameterDirection.Input
                });

                SqlParameter error = new SqlParameter()
                {
                    ParameterName = "@Error",
                    SqlDbType = SqlDbType.VarChar,
                    Size = 1000,
                    Direction = System.Data.ParameterDirection.Output
                };

                SqlParameter validity = new SqlParameter()
                {
                    ParameterName = "@validity",
                    SqlDbType = SqlDbType.Int,
                    Direction = System.Data.ParameterDirection.Output
                };

                parameters.Add(error);
                parameters.Add(validity);

                DataSet dataSet = SqlManager.ExecuteDataSet("SP_LoginAIO", parameters.ToArray());
                errorMessage = error.Value.ToString();
                TempData["Message"] = errorMessage;
                ViewBag.errormsg = errorMessage;
                validityRemaining = validity.Value.ToString();

                try
                {
                    if (errorMessage == "Access Granted")
                    {
                        DataTable dt1 = dataSet.Tables[0];
                        string emailid = "";
                        UserInfo user = new UserInfo();
                        user.validity = validityRemaining;
                        user.FirstName = emailid;

                        if (dt1.Rows.Count > 0)
                        {
                            emailid = dt1.Rows[0]["Emailid"].ToString();
                            user.U_Id = Convert.ToInt32(dt1.Rows[0]["U_ID"]);
                            Session["UID"] = user.U_Id;
                            user.G_Id = Convert.ToInt32(dt1.Rows[0]["Group_Id"]);
                            Session["GID"] = user.G_Id;
                            user.Comp_ID = Convert.ToInt32(dt1.Rows[0]["Comp_ID"]);
                            user.EmailId = dt1.Rows[0]["EmailId"].ToString();
                            user.FirstName = dt1.Rows[0]["FirstName"].ToString();
                            user.LastName = dt1.Rows[0]["LastName"].ToString();
                            user.UserName = dt1.Rows[0]["UserName"].ToString();
                            user.Comp_Type = dt1.Rows[0]["Type"].ToString();
                            user.Active = bool.Parse(dt1.Rows[0]["Active"].ToString());
                            user.Admin_Id = Convert.ToInt32(dt1.Rows[0]["Admin_Id"]);
                            user.Trade_ID = Convert.ToInt32(dt1.Rows[0]["Trade"]);
                            user.Profile_ID = dt1.Rows[0]["Profile"].ToString();

                            user.UserGroupName = dt1.Rows[0]["Group_Name"].ToString();
                            user.CompanyName = dt1.Rows[0]["CompName"].ToString();
                            Session["EmailId"] = dt1.Rows[0]["EmailId"].ToString();
                            Session["FullName"] = user.FirstName + " " + user.LastName;
                            Session["GroupName"] = user.UserGroupName;
                            Session["CompanyName"] = user.CompanyName;
                            Session["ProfileId"] = user.Profile_ID;
                            Session["TradeId"] = user.Trade_ID;
 
                        }

                       
                        Session["UserInfo"] = user;
                        if (IsRemember)
                        {
                            myCookie["username"] = username;
                            myCookie["password"] = password;
                            myCookie.Expires = DateTime.Now.AddDays(15);
                        }
                        else
                        {
                            myCookie["username"] = string.Empty;
                            myCookie["password"] = string.Empty;
                            myCookie.Expires = DateTime.Now.AddMinutes(1);
                        }
                        Response.Cookies.Add(myCookie);
                        Response.SetCookie(myCookie);
                        return RedirectToRoute(new { controller = "Inspire", action = "Admin", id = UrlParameter.Optional });
                    }
                    else
                    {
                        return RedirectToRoute(new { controller = "Login", action = "Login", id = UrlParameter.Optional });
                    }
                }
                catch (Exception)
                {
                    return RedirectToRoute(new { controller = "Login", action = "Login", id = UrlParameter.Optional });
                }
            }
            else
            {
                return RedirectToRoute(new { controller = "Login", action = "Login", id = UrlParameter.Optional });
            }

        }