Пример #1
0
        protected void queryPkgM(object sender)
        {
            try
            {
                System.Data.DataTable dt = new System.Data.DataTable();
                List <System.Web.UI.WebControls.ListItem> listItem = new List <System.Web.UI.WebControls.ListItem>();

                string strSql = "Select * From [HMC_PkgM] Where Rec_Status = 'A' ";
                System.Data.SqlClient.SqlCommand cmd  = new System.Data.SqlClient.SqlCommand(strSql);
                Dev.Sql.MyConnection             conn = new Dev.Sql.MyConnection();
                dt = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        listItem.Add(new System.Web.UI.WebControls.ListItem(dt.Rows[i]["PkgCode"].ToString().Trim() + " " + dt.Rows[i]["Name"].ToString().Trim(), dt.Rows[i]["Id"].ToString().Trim()));
                    }

                    ((System.Web.UI.WebControls.DropDownList)sender).Items.AddRange(listItem.ToArray());
                    ((System.Web.UI.WebControls.DropDownList)sender).DataBind();
                }
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", "PublicLib", ex.Message);
            }
        }
Пример #2
0
    public static void handleError(string ErrorType, string strClass, string strException)
    {
        if (System.Web.Configuration.WebConfigurationManager.AppSettings["SaveError"].Equals("1"))
        {
            string strSql = "Insert Into [ErrorLog] (ID, Class, Exception, Cre_Date) Values (NEWID(), @Class, @Exception, @Cre_Date)";
            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(strSql);
            cmd.Parameters.Add("@Class", System.Data.SqlDbType.VarChar).Value      = strClass;
            cmd.Parameters.Add("@Exception", System.Data.SqlDbType.NVarChar).Value = strException;
            cmd.Parameters.Add("@Cre_Date", System.Data.SqlDbType.DateTime).Value  = DateTime.Now;
            Dev.Sql.MyConnection conn = new Dev.Sql.MyConnection();
            conn.ExecuteQuery(cmd);
        }

        System.Diagnostics.Debug.WriteLine(string.Format("{0}[{1}]{2}", PublicLib.Tag, strClass, strException));
    }