コード例 #1
0
ファイル: Tree.aspx.cs プロジェクト: wrohrbach/n2cms
        protected override void OnInit(EventArgs e)
        {
            FS     = Engine.Resolve <IFileSystem>();
            Config = Engine.Resolve <ConfigurationManagerWrapper>().Sections.Management;
            Register.JQueryUi(Page);
            var selected = Selection.SelectedItem;

            if (IsPostBack && !string.IsNullOrEmpty(inputFile.PostedFile.FileName))
            {
                string uploadFolder = Request[inputLocation.UniqueID];
                if (!IsAvailable(uploadFolder))
                {
                    throw new N2Exception("Cannot upload to " + Server.HtmlEncode(uploadFolder));
                }

                string fileName = System.IO.Path.GetFileName(inputFile.PostedFile.FileName);
                string filePath = Url.Combine(uploadFolder, fileName);
                FS.WriteFile(filePath, inputFile.PostedFile.InputStream);

                ClientScript.RegisterStartupScript(typeof(Tree), "select", "updateOpenerWithUrlAndClose('" + ResolveUrl(filePath) + "');", true);
            }
            else if (Request["location"] == "files" || Request["location"] == "filesselection")
            {
                IHost host = Engine.Resolve <IHost>();
                HierarchyNode <ContentItem> root = new HierarchyNode <ContentItem>(Engine.Persister.Get(host.DefaultSite.RootItemID));

                var selectionTrail = new List <ContentItem>();
                if (selected is AbstractNode)
                {
                    selectionTrail = new List <ContentItem>(Find.EnumerateParents(selected, null, true));
                }
                else
                {
                    TrySelectingPrevious(ref selected, ref selectionTrail);
                }

                foreach (string uploadFolder in Engine.EditManager.UploadFolders)
                {
                    var dd = FS.GetDirectoryOrVirtual(uploadFolder);

                    var dir  = Directory.New(dd, root.Current, Engine.Resolve <IDependencyInjector>());
                    var node = CreateDirectoryNode(FS, dir, root, selectionTrail);
                    root.Children.Add(node);
                }

                AddSiteFilesNodes(root, host.DefaultSite, selectionTrail);
                foreach (var site in host.Sites)
                {
                    if (site.StartPageID == host.DefaultSite.StartPageID)
                    {
                        continue;
                    }

                    AddSiteFilesNodes(root, site, selectionTrail);
                }

                siteTreeView.Nodes        = root;
                siteTreeView.SelectedItem = selected;
            }
            else
            {
                var filter = Engine.EditManager.GetEditorFilter(Page.User);
                siteTreeView.Filter       = filter;
                siteTreeView.RootNode     = Engine.Resolve <Navigator>().Navigate(Request["root"] ?? "/");
                siteTreeView.SelectedItem = selected;
            }

            siteTreeView.SelectableTypes      = Request["selectableTypes"];
            siteTreeView.SelectableExtensions = Request["selectableExtensions"];
            siteTreeView.DataBind();

            inputLocation.Value = siteTreeView.SelectedItem.Url;

            base.OnInit(e);
        }
コード例 #2
0
 protected void btnSave_OnClick(object sender, EventArgs e)
 {
     try
     {
         RouteBo objRouteBo = new RouteBo();
         RouteBl objRouteBl = new RouteBl();
         objRouteBo.RouteNo     = (txtRouteNo.Text.Trim());
         objRouteBo.RouteName   = txtRouteName.Text.Trim();
         objRouteBo.Description = txtDescription.Text.Trim();
         objRouteBo.PLCValue    = Convert.ToInt32(txtPLCValue.Text);
         if (ViewState["Mode"].ToString() == "Save")
         {
             objRouteBo.CreatedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]);
             objRouteBo.CreatedDate = DateTime.UtcNow.AddHours(5.5);
             var objResult = objRouteBl.Route_Insert(objRouteBo);
             if (objResult != null)
             {
                 if (objResult.ResultDt.Rows.Count > 0)
                 {
                     int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString());
                     if (intStatus == 0)
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Route Name or Route No is already exist.');</script>");
                     }
                     else
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Saved Successfully.');</script>");
                         ClearAll();
                         BindgvRoute();
                         PanelVisibilityMode(true, false);
                     }
                 }
             }
         }
         else if (ViewState["Mode"].ToString() == "Edit")
         {
             objRouteBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]);
             objRouteBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5);
             objRouteBo.Id = Convert.ToInt32(ViewState["RouteID"].ToString());
             var objResult = objRouteBl.Route_Update(objRouteBo);
             if (objResult != null)
             {
                 if (objResult.ResultDt.Rows.Count > 0)
                 {
                     int intStatus = Convert.ToInt32(objResult.ResultDt.Rows[0]["Status"].ToString());
                     if (intStatus == 0)
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Route Name or Route No is already exist.');</script>");
                     }
                     else
                     {
                         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Updated Successfully.');</script>");
                         ClearAll();
                         BindgvRoute();
                         PanelVisibilityMode(true, false);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Error", ex);
         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
     }
 }
コード例 #3
0
 protected void btRepm_Click(object sender, EventArgs e)
 {
     ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "abrirVentana('Reportes/ReporteClientes.aspx')", true);
 }
コード例 #4
0
        private void CloseForm()
        {
            string nUrl = "<script>CloseOnReload()</script>";

            ClientScript.RegisterStartupScript(this.GetType(), "closeWindow", nUrl);
        }
コード例 #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString())
                {
                    Session["CheckRefresh"] =
                        Server.UrlDecode(System.DateTime.Now.ToString());

                    FeesCategoryBO    objFeesBo   = new FeesCategoryBO();
                    ApplicationResult objResults  = new ApplicationResult();
                    FeesCategoryBL    objFeesBl   = new FeesCategoryBL();
                    Controls          objControls = new Controls();

                    objFeesBo.TrustMID         = Convert.ToInt32(Session[ApplicationSession.TRUSTID]);
                    objFeesBo.SchoolMID        = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]);
                    objFeesBo.FeesName         = txtFeesCategoryName.Text;
                    objFeesBo.FeesType         = rblFeeType.SelectedItem.Text;
                    objFeesBo.OutstandingMonth = Convert.ToInt32(ddlOutstandingMonth.SelectedValue);
                    objFeesBo.FeeAbbreviation  = txtAbbreviation.Text;
                    objFeesBo.FeeGroupID       = Convert.ToInt32(ddlFeeGroup.SelectedValue);

                    objFeesBo.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                    objFeesBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    if (ValidateName() == true)
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Fees Category Name " + txtFeesCategoryName.Text + " Already Exists');</script>");
                        goto Exit;
                    }
                    if (ViewState["Mode"].ToString() == "Save")
                    {
                        objResults = objFeesBl.FeesCategory_Insert(objFeesBo);

                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClearAll();
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Fees Category Created Successfully.');</script>");
                            GridDataBind();
                            PanelGrid_VisibilityMode(1);
                        }
                    }
                    else
                    {
                        objFeesBo.FeesCategoryMID = Convert.ToInt32(ViewState["FeesCategoryMID"].ToString());

                        objResults = objFeesBl.FeesCategory_Update(objFeesBo);
                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Fee Category updated successfully.');</script>");

                            GridDataBind();
                            ClearAll();
                            //objControls.ClearForm(Master.FindControl("ContentPlaceHolder1"));
                            ViewState["Mode"] = "Save";
                            btnSave.Text      = "Save";
                        }
                    }
                    Exit :;
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
        }
コード例 #6
0
ファイル: Page7.aspx.cs プロジェクト: srtaseen/OtsGit
    protected void TnALoad_Click(object sender, EventArgs e)
    {
        {
            int TnaID = 0;

            SqlConnection conn = new SqlConnection(DbConnect.x);
            using (SqlConnection con = new SqlConnection(DbConnect.x))
            {
                using (SqlCommand Syscmd = new SqlCommand("Sp_TNA_Plan"))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        Syscmd.CommandType = CommandType.StoredProcedure;
                        Syscmd.Parameters.AddWithValue("TnaByrNm", ddlbuyer.SelectedValue);
                        Syscmd.Parameters.AddWithValue("TnaOrdNm", ddlStyle.SelectedValue);
                        Syscmd.Parameters.AddWithValue("TnaPoNm", DropDownpo.SelectedValue);
                        Syscmd.Parameters.AddWithValue("TnaBpcd", txtbpsd.Text.Trim());
                        Syscmd.Parameters.AddWithValue("TnaLedTm", txtled.Text.Trim());
                        Syscmd.Parameters.AddWithValue("TnaAcMangr", ddlusername.SelectedValue);
                        Syscmd.Parameters.AddWithValue("TnaCetegory", ddTnacategory.SelectedValue);
                        Syscmd.Parameters.AddWithValue("Tnapl1", lblpl1.Text.Trim());   //lab dip
                        Syscmd.Parameters.AddWithValue("Tnapl2", lblpl2.Text.Trim());   //lab dip app
                        Syscmd.Parameters.AddWithValue("Tnapl3", lblpl3.Text.Trim());   //accessories booking
                        Syscmd.Parameters.AddWithValue("Tnapl4", lblpl4.Text.Trim());   //fabric booking
                        Syscmd.Parameters.AddWithValue("Tnapl5", lblpl5.Text.Trim());   //yarn booking
                        Syscmd.Parameters.AddWithValue("Tnapl6", lblpl6.Text.Trim());   //1
                        Syscmd.Parameters.AddWithValue("Tnapl7", lblpl7.Text.Trim());   //2
                        Syscmd.Parameters.AddWithValue("Tnapl8", lblpl8.Text.Trim());   //3
                        Syscmd.Parameters.AddWithValue("Tnapl9", lblpl9.Text.Trim());   //4
                        Syscmd.Parameters.AddWithValue("Tnapl10", lblpl10.Text.Trim()); //5
                        Syscmd.Parameters.AddWithValue("Tnapl11", lblpl11.Text.Trim()); //6
                        Syscmd.Parameters.AddWithValue("Tnapl12", lblpl12.Text.Trim()); //7
                        Syscmd.Parameters.AddWithValue("Tnapl13", lblpl13.Text.Trim()); //8
                        Syscmd.Parameters.AddWithValue("Tnapl14", lblpl14.Text.Trim()); //9
                        Syscmd.Parameters.AddWithValue("Tnapl15", lblpl15.Text.Trim()); //10
                        Syscmd.Parameters.AddWithValue("Tnapl16", lblpl16.Text.Trim()); //11
                        Syscmd.Parameters.AddWithValue("Tnapl17", lblpl17.Text.Trim()); //12
                        Syscmd.Parameters.AddWithValue("Tnapl18", lblpl18.Text.Trim()); //13
                        Syscmd.Parameters.AddWithValue("Tnapl19", lblpl19.Text.Trim()); //14
                        Syscmd.Parameters.AddWithValue("Tnapl20", lblpl20.Text.Trim()); //15
                        Syscmd.Parameters.AddWithValue("Tnapl21", lblpl21.Text.Trim()); //Pi recv
                        Syscmd.Parameters.AddWithValue("Tnapl22", lblpl22.Text.Trim()); //BBlc open
                        Syscmd.Parameters.AddWithValue("Tnapl23", lblpl23.Text.Trim()); //Yarn inhose strt
                        Syscmd.Parameters.AddWithValue("Tnapl24", lblpl24.Text.Trim()); //Yarn inhouse end
                        Syscmd.Parameters.AddWithValue("Tnapl25", lblpl25.Text.Trim()); //Knit Strt
                        Syscmd.Parameters.AddWithValue("Tnapl26", lblpl26.Text.Trim()); //Knit end
                        Syscmd.Parameters.AddWithValue("Tnapl27", lblpl27.Text.Trim()); //Dye Start
                        Syscmd.Parameters.AddWithValue("Tnapl28", lblpl28.Text.Trim()); //Dye end
                        Syscmd.Parameters.AddWithValue("Tnapl29", lblpl29.Text.Trim()); //Accessories Production Start
                        Syscmd.Parameters.AddWithValue("Tnapl30", lblpl30.Text.Trim()); //Accessories Production End
                        Syscmd.Parameters.AddWithValue("Tnapl31", lblpl31.Text.Trim()); //Sewing Trims Inhouse Start
                        Syscmd.Parameters.AddWithValue("Tnapl32", lblpl32.Text.Trim()); //Sewing Trims Inhouse end
                        Syscmd.Parameters.AddWithValue("Tnapl33", lblpl33.Text.Trim()); //Finishing Trims Inhouse start
                        Syscmd.Parameters.AddWithValue("Tnapl34", lblpl34.Text.Trim()); //Finishing Trims Inhouse end
                        Syscmd.Parameters.AddWithValue("Tnapl35", lblpl35.Text.Trim()); //PP Meeting/Trial Cut
                        Syscmd.Parameters.AddWithValue("Tnapl36", lblpl36.Text.Trim()); //Bulk Cutting Start
                        Syscmd.Parameters.AddWithValue("Tnapl37", lblpl37.Text.Trim()); //Bulk Cutting Finished
                        Syscmd.Parameters.AddWithValue("Tnapl38", lblpl38.Text.Trim()); //Print Start
                        Syscmd.Parameters.AddWithValue("Tnapl39", lblpl39.Text.Trim()); //Print Finished
                        Syscmd.Parameters.AddWithValue("Tnapl40", lblpl30.Text.Trim()); //EMB Start
                        Syscmd.Parameters.AddWithValue("Tnapl41", lblpl41.Text.Trim()); //EMB Finished
                        Syscmd.Parameters.AddWithValue("Tnapl42", lblpl42.Text.Trim()); //Sewing Start
                        Syscmd.Parameters.AddWithValue("Tnapl43", lblpl43.Text.Trim()); //Sewing Finished
                        Syscmd.Parameters.AddWithValue("Tnapl44", lblpl44.Text.Trim()); //Wash Start
                        Syscmd.Parameters.AddWithValue("Tnapl45", lblpl45.Text.Trim()); //Wash Finished
                        Syscmd.Parameters.AddWithValue("Tnapl46", lblpl46.Text.Trim()); //1
                        Syscmd.Parameters.AddWithValue("Tnapl47", lblpl47.Text.Trim()); //2
                        Syscmd.Parameters.AddWithValue("Tnapl48", lblpl48.Text.Trim()); //3
                        Syscmd.Parameters.AddWithValue("Tnapl49", lblpl49.Text.Trim()); //4
                        Syscmd.Parameters.AddWithValue("Tnapl50", lblpl50.Text.Trim()); //5
                        Syscmd.Parameters.AddWithValue("Tnapl51", lblpl51.Text.Trim()); //6
                        Syscmd.Parameters.AddWithValue("Tnapl52", lblpl52.Text.Trim()); //Finishing Start
                        Syscmd.Parameters.AddWithValue("Tnapl53", lblpl53.Text.Trim()); //Finishing End
                        Syscmd.Parameters.AddWithValue("Tnapl54", lblpl54.Text.Trim()); //Pre Final Ins
                        Syscmd.Parameters.AddWithValue("Tnapl55", lblpl55.Text.Trim()); // Final Ins
                        Syscmd.Parameters.AddWithValue("Tnapl56", lblpl56.Text.Trim()); //YD start
                        Syscmd.Parameters.AddWithValue("Tnapl57", lblpl57.Text.Trim()); //YD end
                        Syscmd.Parameters.AddWithValue("Tnapl58", lblpl58.Text.Trim()); //AOP start
                        Syscmd.Parameters.AddWithValue("Tnapl59", lblpl59.Text.Trim()); //AOP end
                        Syscmd.Parameters.AddWithValue("Tnapl60", lblpl60.Text.Trim()); //AOP end
                        Syscmd.Parameters.AddWithValue("Tnapl61", lblpl61.Text.Trim()); //AOP end

                        Syscmd.Connection = con;
                        con.Open();
                        TnaID = Convert.ToInt32(Syscmd.ExecuteScalar());

                        con.Close();
                    }
                }

                string message = string.Empty;
                switch (TnaID)
                {
                case -1:
                    message = "Username already exists.\\nPlease choose a different username.";
                    break;

                case -2:
                    message = "Supplied email address has already been used.";
                    break;

                default:
                    message = "Registration successful. Activation email has been sent to your email.";
                    //SendTNALoadEmail(UserId);
                    break;
                }
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true);
            }
            Response.Redirect(Request.RawUrl); //page refreash
        }
    }
コード例 #7
0
        protected void Login_Click(object sender, EventArgs e)
        {
            //Get the information of the connection to the database
            string connStr = ConfigurationManager.ConnectionStrings["MyDbConn"].ToString();

            //create a new connection
            SqlConnection conn = new SqlConnection(connStr);

            /*create a new SQL command which takes as parameters the name of the stored procedure and
             * the SQLconnection name*/
            SqlCommand cmd = new SqlCommand("userLogin", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            //To read the input from the user

            string username = UsernameText.Text;
            string password = PasswordText.Text;


            cmd.Parameters.Add(new SqlParameter("@username", username));
            cmd.Parameters.Add(new SqlParameter("@password", password));

            SqlParameter success = cmd.Parameters.Add("@success", SqlDbType.Bit);

            success.Direction = ParameterDirection.Output;
            SqlParameter type = cmd.Parameters.Add("@type", SqlDbType.Int);

            type.Direction    = ParameterDirection.Output;
            conn.InfoMessage += new SqlInfoMessageEventHandler(myConnection_InfoMessage);



            //Executing the SQLCommand
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();

            //Response.Write((success.Value).ToString());
            if (success.Value.ToString().Equals("True"))
            {
                Session["username"] = username;
                //Response.Write(username);
                if (type.Value.ToString().Equals("0"))
                {
                    Response.Redirect("Customer_1.aspx");
                }
                else if (type.Value.ToString().Equals("1"))
                {
                    Response.Redirect("VendorPage0.aspx");
                }
                else if (type.Value.ToString().Equals("2"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "You are an Admin" + "');", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "You a delivery personnel" + "');", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Wrong username or password" + "');", true);
            }
        }
コード例 #8
0
    protected void submitBtn_Click(object sender, EventArgs e)
    {
        string timeStart      = hrStart.SelectedItem.ToString() + ":" + minStart.SelectedItem.ToString();
        string timeEnd        = hrEnd.SelectedItem.ToString() + ":" + minEnd.SelectedItem.ToString();
        bool   emptyPartInput = lastNameTxt.Text == "" || firstNameTxt.Text == "" || ageTxt.Text == "" || emailAddTxt.Text == "" || datepicker.Text == "" || datepicker1.Text == "";

        if (emptyPartInput == true)
        {
            string errorM = "window.onload = function() { errorMessage('Kindly fill out all fields'); };";
            ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", errorM, true);
        }
        else
        {
            //checkIfwronginput
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();

                    SqlCommand checkEventInfo = new SqlCommand(@"SELECT COUNT(*) AS 'eventCount'
                                                             FROM tb_EventInfo EI JOIN tb_Schedule S ON EI.scheduleID = s.scheduleID
                                                             WHERE ((eventName = @eventName AND dateStart = @dateStart) 
                                                             AND (dateEnd = @dateEnd AND timeStart = @timeStart))
                                                             AND (timeEnd = @timeEnd AND venueName = @venueName)", con);

                    checkEventInfo.Parameters.AddWithValue("@eventName", eventNameList.SelectedItem.ToString());
                    checkEventInfo.Parameters.AddWithValue("@dateStart", datepicker.Text);
                    checkEventInfo.Parameters.AddWithValue("@dateEnd", datepicker1.Text);
                    checkEventInfo.Parameters.AddWithValue("@timeStart", timeStart);
                    checkEventInfo.Parameters.AddWithValue("@timeEnd", timeEnd);
                    checkEventInfo.Parameters.AddWithValue("@venueName", venueTxt.Text);

                    SqlDataReader reader = checkEventInfo.ExecuteReader();

                    while (reader.Read())
                    {
                        checkCount = (int)reader["eventCount"];
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "');</script>");
            }
            finally
            {
                con.Close();
            }

            if (checkCount == 0)
            {
                string errorM = "window.onload = function() { errorMessage('Event not existing. Make sure to input the right info about your chosen event'); };";
                ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", errorM, true);
            }
            else
            {
                //getSchedID
                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();

                        SqlCommand getSchedID = new SqlCommand(@"SELECT S.scheduleID AS 'scheduleID', ticketAmount, fbGroupCode
                                                             FROM tb_EventInfo EI JOIN tb_Schedule S ON EI.scheduleID = S.scheduleID
                                                             WHERE ((eventName = @eventName AND dateStart = @dateStart) 
                                                             AND (dateEnd = @dateEnd AND timeStart = @timeStart))
                                                             AND (timeEnd = @timeEnd AND venueName = @venueName)", con);

                        getSchedID.Parameters.AddWithValue("@eventName", eventNameList.SelectedItem.ToString());
                        getSchedID.Parameters.AddWithValue("@dateStart", datepicker.Text);
                        getSchedID.Parameters.AddWithValue("@dateEnd", datepicker1.Text);
                        getSchedID.Parameters.AddWithValue("@timeStart", timeStart);
                        getSchedID.Parameters.AddWithValue("@timeEnd", timeEnd);
                        getSchedID.Parameters.AddWithValue("@venueName", venueTxt.Text);

                        SqlDataReader reader = getSchedID.ExecuteReader();

                        while (reader.Read())
                        {
                            schedID    = (int)reader["scheduleID"];
                            tickAmount = Convert.ToDouble((decimal)reader["ticketAmount"]);
                            fbCode     = (string)reader["fbGroupCode"];
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "');</script>");
                }
                finally
                {
                    con.Close();
                }

                //insertTo_tb_Ticket
                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();

                        SqlCommand insTicket = new SqlCommand(@"INSERT INTO tb_Ticket
                                                             VALUES(@schedID, @participantID,
                                                             @qrCode, @paymentStatus, @isScanned)", con);
                        insTicket.Parameters.AddWithValue("@schedID", schedID);
                        insTicket.Parameters.AddWithValue("@participantID", participantIdLbl.Text);
                        insTicket.Parameters.AddWithValue("@qrCode", participantIdLbl.Text + schedID.ToString());

                        string status = "";
                        if (tickAmount == 0)
                        {
                            status            = "PAID";
                            successfulMessage = "SAVE YOUR QR TICKET NOW!, if you want to receive new updates about your chosen event you may join the Facebook Group https://www.facebook.com/groups/" + fbCode + "/";
                        }
                        else
                        {
                            status            = "UNPAID";
                            successfulMessage = "SAVE YOUR QR VOUCHER NOW!, make sure to pay as soon as possible to complete your registration and join the Facebook Group https://www.facebook.com/groups/" + fbCode + "/ To keep updated about your chosen event.";
                        }
                        insTicket.Parameters.AddWithValue("@paymentStatus", status);
                        insTicket.Parameters.AddWithValue("@isScanned", false);
                        insTicket.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "');</script>");
                }
                finally
                {
                    con.Close();
                }

                //inserttoParticipant_tb
                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();

                        SqlCommand insParticipant = new SqlCommand(@"INSERT INTO tb_participantInformations
                                                                     VALUES(@participantID, @lastName,
                                                                     @firstName, @age, @scheduleID, @contactNum)", con);

                        insParticipant.Parameters.AddWithValue("@participantID", participantIdLbl.Text);
                        insParticipant.Parameters.AddWithValue("@lastName", lastNameTxt.Text);
                        insParticipant.Parameters.AddWithValue("@firstName", firstNameTxt.Text);
                        insParticipant.Parameters.AddWithValue("@age", ageTxt.Text);
                        insParticipant.Parameters.AddWithValue("@contactNum", emailAddTxt.Text);
                        insParticipant.Parameters.AddWithValue("@scheduleID", schedID);

                        insParticipant.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "');</script>");
                }
                finally
                {
                    con.Close();
                }


                QRCodeEncoder encoder = new QRCodeEncoder();

                Bitmap img = encoder.Encode(participantIdLbl.Text + schedID.ToString());

                img = new Bitmap(img, new Size(100, 100));
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                img.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
                byte[] imageBytes = stream.ToArray();

                string path = Convert.ToBase64String(imageBytes);
                QRImage.ImageUrl = "data:image/png;base64," + path;

                string script = "window.onload = function() { alertMessage('" + successfulMessage + "'); };";
                ClientScript.RegisterStartupScript(this.GetType(), "alertMessage", script, true);
                idGenerator();
            }
        }
    }
コード例 #9
0
ファイル: NewRFP.aspx.cs プロジェクト: blackmamba85/BHTheApp
        /// <summary>
        /// Submit the RFP in the system
        /// </summary>
        protected void Submit_Click(object sender, EventArgs e)
        {
            RFP     rfp          = new RFP();
            decimal gatewayPrice = Convert.ToDecimal(this.txtgatewayPrice.Text);
            int     rfpid;

            rfp.CreateNewRFP(ddRFI.SelectedIndex, UserInfoBoxControl.UserID, gatewayPrice, lblstartdate.Text, lblenddate.Text);
            rfpid = rfp.GetLastRFP_IDinserted();


            int index = 0;//index use to step through the permissionlist

            foreach (var vendor in vendorlist)
            {
                try
                {
                    string insertQry = "Insert into [BHSCMS].[dbo].[VendorRFPTable] (RFP_ID, VendorID, PermissionID) Values (@rfpId, @vendorid, @permissionId)";

                    string connString = ConfigurationManager.ConnectionStrings["BHSCMS"].ConnectionString;

                    SqlConnection conn = new SqlConnection(connString);
                    SqlCommand    cmd  = new SqlCommand(insertQry, conn);
                    conn.Open();

                    cmd.Parameters.AddWithValue("@rfpId", rfpid);
                    cmd.Parameters.AddWithValue("@vendorid", vendor);
                    cmd.Parameters.AddWithValue("@permissionId", permissionlist[index]);
                    cmd.ExecuteNonQuery();


                    conn.Close();

                    index++;//increases the index of permissionID list
                }
                catch (Exception ex)
                {
                }
            }


            if (fileList != null && fileList.Count > 0)
            {
                foreach (DocumentFile file in fileList)
                {
                    file.ReferenceID = rfpid;
                    file.TypeID      = 3;
                    FunctionsHelper.UploadDocument(file);
                }
            }
            else
            {
                //Alert the user that something bad has happened
                string startupScript = "alert('Document Upload failed please try again. Or contact an IS Admin')";
                ClientScript.RegisterStartupScript(GetType(), "startupScript", startupScript);
            }



            reviewPanel.Visible     = false;
            setupPanel.Visible      = false;
            panelVendors.Visible    = false;
            panelvendorlist.Visible = false;

            ddRFI.Visible              = false;
            ddlRFIlabel.Visible        = false;
            txtRFIProduct.Visible      = false;
            txtRFIProductlabel.Visible = false;

            RFPsubmit.Visible = true;
            lblsuccess.Text   = "The RFP has been successfully submitted";

            fileList       = null;
            vendorlist     = null;//static lists are cleared to be used again
            permissionlist = null;
            companylist    = null;
        }
コード例 #10
0
        protected void buttonUpdate_OnClick(object sender, EventArgs e)
        {
            var listSettings = new List <EntitySetting>
            {
                new EntitySetting
                {
                    Name  = SettingStrings.PxeBootloader,
                    Value = ddlPxeBootloader.Text,
                    Id    = Call.SettingApi.GetSetting(SettingStrings.PxeBootloader).Id
                },
                new EntitySetting
                {
                    Name  = SettingStrings.ProxyDhcpEnabled,
                    Value = ddlProxyDhcp.Text,
                    Id    = Call.SettingApi.GetSetting(SettingStrings.ProxyDhcpEnabled).Id
                },
                new EntitySetting
                {
                    Name  = SettingStrings.ProxyBiosBootloader,
                    Value = ddlProxyBios.Text,
                    Id    = Call.SettingApi.GetSetting(SettingStrings.ProxyBiosBootloader).Id
                },
                new EntitySetting
                {
                    Name  = SettingStrings.ProxyEfi32Bootloader,
                    Value = ddlProxyEfi32.Text,
                    Id    = Call.SettingApi.GetSetting(SettingStrings.ProxyEfi32Bootloader).Id
                },
                new EntitySetting
                {
                    Name  = SettingStrings.ProxyEfi64Bootloader,
                    Value = ddlProxyEfi64.Text,
                    Id    = Call.SettingApi.GetSetting(SettingStrings.ProxyEfi64Bootloader).Id
                },
            };

            var result = Call.SettingApi.UpdatePxeSettings(listSettings);

            EndUserMessage = result
                ? "Successfully Updated Settings"
                : "Could Not Update Settings";

            var newBootMenu = false;

            if (!Call.SettingApi.CopyPxeBinaries())
            {
                EndUserMessage = "Updated Settings Successfully, But Could Not Copy PXE Binaries On One Or More Com Servers.  Check The Logs For More Info.";
                return;
            }

            if ((string)ViewState["proxyDhcp"] != ddlProxyDhcp.Text)
            {
                newBootMenu = true;
            }
            if ((string)ViewState["proxyBios"] != ddlProxyBios.Text)
            {
                newBootMenu = true;
            }
            if ((string)ViewState["proxyEfi32"] != ddlProxyEfi32.Text)
            {
                newBootMenu = true;
            }
            if ((string)ViewState["proxyEfi64"] != ddlProxyEfi64.Text)
            {
                newBootMenu = true;
            }
            if ((string)ViewState["pxeBootloader"] != ddlPxeBootloader.Text)
            {
                newBootMenu = true;
            }

            if (newBootMenu)
            {
                lblTitle.Text =
                    "Your Settings Changes Require A New PXE Boot File Be Created.  <br>Go There Now?";

                ClientScript.RegisterStartupScript(GetType(), "modalscript",
                                                   "$(function() {  var menuTop = document.getElementById('confirmbox'),body = document.body;classie.toggle(menuTop, 'confirm-box-outer-open'); });",
                                                   true);
                Session.Remove("Message");
            }
            else
            {
                EndUserMessage = "Successfully Updated PXE Settings";
            }

            //Update the viewstate
            ViewState["pxeBootloader"] = ddlPxeBootloader.Text;
            ViewState["proxyDhcp"]     = ddlProxyDhcp.SelectedValue;
            ViewState["proxyBios"]     = ddlProxyBios.SelectedValue;
            ViewState["proxyEfi32"]    = ddlProxyEfi32.SelectedValue;
            ViewState["proxyEfi64"]    = ddlProxyEfi64.SelectedValue;

            EndUserMessage = "Successfully Updated PXE Settings";
        }
コード例 #11
0
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     string script = "<script>RefreshParentPage()</" + "script>";
     //RadScriptManager.RegisterStartupScript(this, this.GetType(), "RefreshParentPage", script, false);
     ClientScript.RegisterStartupScript(this.GetType(), "RefreshParentPage", script);
 }
コード例 #12
0
 protected void btnCloseTop_Click(object sender, EventArgs e)
 {
     ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);
 }
コード例 #13
0
        public void BindReportData()
        {
            try
            {
                ApplicationResult objResult      = new ApplicationResult();
                DateTime          dtFromDateTime = DateTime.ParseExact(txtFromDate.Text + " " + txtFromTime.Text, "dd/MM/yyyy HH:mm:ss",
                                                                       CultureInfo.InvariantCulture);
                DateTime dtToDateTime = DateTime.ParseExact(txtToDate.Text + " " + txtToTime.Text, "dd/MM/yyyy HH:mm:ss",
                                                            CultureInfo.InvariantCulture);
                int intGraphId = Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString());
                // objResult = new MilkReceptionBL().MilkReception_SelectAll(dtFromDateTime, dtToDateTime, Convert.ToInt32(ddlShiftNo.SelectedValue), Convert.ToInt32(ddlTankerID.SelectedValue), Convert.ToDouble(ddlReceptionLineNo.SelectedValue), Convert.ToDouble(ddlSILONo.SelectedValue));

                objResult = new TempratureTrendBL().GetALl_TemperatureTrendDataReport(dtFromDateTime, dtToDateTime, intGraphId);
                //ViewState["DataTableMilkStorage"] = objResult.ResutlDs.Tables[0];

                gvTrendData.DataSource = null;
                gvTrendData.DataBind();

                gvTrendData.DataSource = objResult.ResultDt;
                gvTrendData.DataBind();
                //gvTotalQty.DataSource = objResult.ResutlDs.Tables[1];
                //gvTotalQty.DataBind();

                if (gvTrendData.Rows.Count > 1)
                {
                    imgbtnPDF.Visible = imgbtnExcel.Visible = divNo.Visible = true;
                    divNo.Visible     = false;

                    if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 1)
                    {
                        lblHeader1.Text = "MPL-1 Temperature Report";
                        lblHeader2.Text = "MPL-1 Temperature Report";
                    }
                    else if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 2)
                    {
                        lblHeader1.Text = "MPL-2 Temperature Report";
                        lblHeader2.Text = "MPL-2 Temperature Report";
                    }
                    else if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 3)
                    {
                        lblHeader1.Text = "CPL Temperature Report";
                        lblHeader2.Text = "CPL Temperature Report";
                    }
                    else if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 4)
                    {
                        lblHeader1.Text = "Curd Temperature Report";
                        lblHeader2.Text = "Curd Temperature Report";
                    }
                    else if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 5)
                    {
                        lblHeader1.Text = "BM Temperature Report";
                        lblHeader2.Text = "BM Temperature Report";
                    }
                    else if (Convert.ToInt32(ddlPasteuriser.SelectedValue.ToString()) == 6)
                    {
                        lblHeader1.Text = "MPLBM Temperature Report";
                        lblHeader2.Text = "MPLBM Temperature Report";
                    }
                }
                else
                {
                    imgbtnPDF.Visible      = imgbtnExcel.Visible = divNo.Visible = false;
                    divNo.Visible          = true;
                    gvTrendData.DataSource = null;
                    gvTrendData.DataBind();

                    // ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                    //"<script>alert('No Record Found.');</script>");
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                   "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
            }
        }
コード例 #14
0
ファイル: News.aspx.cs プロジェクト: Imariscal/WebFormsPOC
        public void OnError(string errorMessage)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Javascript", "javascript:alert('" + errorMessage + "'); ", true);

        }
コード例 #15
0
        protected void txtSoldQuantity_TextChanged(object sender, EventArgs e)
        {
            try
            {
                int sQty    = int.Parse(txtQuantity.Text);
                int soldQty = int.Parse(txtSoldQuantity.Text);

                if (soldQty > sQty)
                {
                    ClientScript.RegisterStartupScript(GetType(), "key", "<script>alert('Actual Price if more than the Selling Price!!!')</script>");
                    btnAdd.Enabled = false;
                }
                else
                {
                    double investment = double.Parse(txtInvestment.Value);
                    double cost       = double.Parse(txtCost.Value);

                    int    soldQuantity = int.Parse(txtSoldQuantity.Text);
                    double totalCost    = soldQuantity * cost;

                    double gain = totalCost - investment;

                    double profitPercentage = (gain * 100.0) / investment;

                    if (profitPercentage < 0)
                    {
                        lblProfit.Text  = "Loss = " + gain + "units and percentage = " + profitPercentage.ToString() + "% Loss";
                        txtProfit.Value = "Loss";
                    }
                    else if (profitPercentage == 0)
                    {
                        lblProfit.Text  = "No Profit/No Loss";
                        txtProfit.Value = "No Profit/No Loss";
                    }
                    else if (profitPercentage > 0 && profitPercentage < 40)
                    {
                        lblProfit.Text  = "Gain = " + gain + "units and percentage = " + profitPercentage.ToString() + "% Profit";
                        txtProfit.Value = "LessProfit";
                    }
                    else if (profitPercentage >= 40 && profitPercentage < 60)
                    {
                        lblProfit.Text  = "Gain = " + gain + "units and percentage = " + profitPercentage.ToString() + "% Profit";
                        txtProfit.Value = "MediumProfit";
                    }
                    else
                    {
                        if (profitPercentage >= 80)
                        {
                            lblProfit.Text  = "Gain = " + gain + "units and percentage = " + profitPercentage.ToString() + "% Profit";
                            txtProfit.Value = "HighProfit";
                        }
                    }

                    btnAdd.Enabled = true;
                }
            }
            catch
            {
                ClientScript.RegisterStartupScript(GetType(), "key", "<script>alert('Server Error - Check the Database Connectivity!!!')</script>");
            }
        }
コード例 #16
0
    protected void lbNewWindow_Click(object sender, EventArgs e)
    {
        string g = "window.open('" + google + "', 'popup_window', 'width=1024,height=768,left=100,top=100,resizable=yes');";

        ClientScript.RegisterStartupScript(this.GetType(), "script", g, true);
    }
コード例 #17
0
        //function to get company products
        private void GetProducts()
        {
            DataTable tab = new DataTable();
            BLL       obj = new BLL();

            try
            {
                if (dropdownlistCategories.SelectedIndex > 0)
                {
                    tab = obj.GetProductsByCategory(int.Parse(dropdownlistCategories.SelectedValue));
                }
                else
                {
                    tab = obj.GetProductsByCompany(Session["CompanyId"].ToString());
                }

                if (tab.Rows.Count > 0)
                {
                    tableProducts.Rows.Clear();

                    tableProducts.BorderStyle = BorderStyle.Double;
                    tableProducts.GridLines   = GridLines.Both;
                    tableProducts.BorderColor = System.Drawing.Color.DarkGray;

                    TableRow headerrow = new TableRow();
                    headerrow.Height    = 30;
                    headerrow.ForeColor = System.Drawing.Color.WhiteSmoke;
                    headerrow.BackColor = System.Drawing.Color.Gray;

                    TableCell cell1 = new TableCell();
                    cell1.Text = "<b>Photo</b>";
                    headerrow.Controls.Add(cell1);

                    TableCell cell3 = new TableCell();
                    cell3.Text = "<b>Category Name</b>";
                    headerrow.Controls.Add(cell3);

                    TableCell cell4 = new TableCell();
                    cell4.Text = "<b>Product Name</b>";
                    headerrow.Controls.Add(cell4);

                    TableCell cell5 = new TableCell();
                    cell5.Text = "<b>Cost</b>";
                    headerrow.Controls.Add(cell5);

                    TableCell cell8 = new TableCell();
                    cell8.Text = "Rating";
                    headerrow.Controls.Add(cell8);

                    if (dropdownlistCategories.SelectedIndex > 0)
                    {
                        TableCell cell6 = new TableCell();
                        cell6.Text = "<b>Edit</b>";
                        headerrow.Controls.Add(cell6);

                        TableCell cell7 = new TableCell();
                        cell7.Text = "<b>Delete</b>";
                        headerrow.Controls.Add(cell7);
                    }
                    else
                    {
                    }

                    tableProducts.Controls.Add(headerrow);

                    for (int cnt = 0; cnt < tab.Rows.Count; cnt++)
                    {
                        TableRow row = new TableRow();
                        row.Height = 30;

                        TableCell cellPhoto = new TableCell();
                        cellPhoto.VerticalAlign = VerticalAlign.Top;
                        cellPhoto.Width         = 50;
                        cellPhoto.Height        = 50;
                        Image imgPhoto = new Image();
                        imgPhoto.Width    = 50;
                        imgPhoto.Height   = 50;
                        imgPhoto.ImageUrl = tab.Rows[cnt]["ProductPhoto"].ToString();
                        cellPhoto.Controls.Add(imgPhoto);
                        row.Controls.Add(cellPhoto);

                        TableCell cellType = new TableCell();
                        cellType.Width = 150;

                        DataTable tabCategory = new DataTable();
                        tabCategory = obj.GetCategoryById(int.Parse(tab.Rows[cnt]["CategoryId"].ToString()));

                        cellType.Text = tabCategory.Rows[0]["CategoryName"].ToString();
                        row.Controls.Add(cellType);

                        TableCell cellPName = new TableCell();
                        cellPName.Width = 150;

                        if (dropdownlistCategories.SelectedIndex > 0)
                        {
                            HyperLink hypPName = new HyperLink();
                            hypPName.Text        = tab.Rows[cnt]["ProductName"].ToString();
                            hypPName.NavigateUrl = string.Format("~/Company/AddProductFeatures.aspx?categoryId={0}&productId={1}&productName={2}", dropdownlistCategories.SelectedValue, tab.Rows[cnt]["ProductId"].ToString(), tab.Rows[cnt]["ProductName"].ToString());
                            cellPName.Controls.Add(hypPName);
                        }
                        else
                        {
                            cellPName.Text = tab.Rows[cnt]["ProductName"].ToString();
                        }

                        row.Controls.Add(cellPName);

                        TableCell cellCost = new TableCell();
                        cellCost.Width = 80;
                        cellCost.Text  = tab.Rows[cnt]["ProductCost"].ToString();
                        row.Controls.Add(cellCost);

                        TableCell cellratings = new TableCell();
                        cellratings.Width = 80;

                        DataTable tabRatings = new DataTable();
                        tabRatings = obj.GetRatingsByProduct(int.Parse(tab.Rows[cnt]["ProductId"].ToString()));

                        int rating = 0;

                        if (tabRatings.Rows.Count > 0)
                        {
                            rating = obj.GetProductRatings(int.Parse(tab.Rows[cnt]["ProductId"].ToString()));
                        }
                        else
                        {
                            rating = 0;
                        }

                        HyperLink hypRating = new HyperLink();
                        hypRating.Text        = rating.ToString();
                        hypRating.NavigateUrl = string.Format("~/Company/Ratings.aspx?productId={0}&productName={1}", tab.Rows[cnt]["ProductId"].ToString(), tab.Rows[cnt]["ProductName"].ToString());
                        cellratings.Controls.Add(hypRating);
                        row.Controls.Add(cellratings);

                        if (dropdownlistCategories.SelectedIndex > 0)
                        {
                            TableCell cellEdit = new TableCell();

                            ImageButton btnEdit = new ImageButton();
                            btnEdit.Width    = 15;
                            btnEdit.Height   = 15;
                            btnEdit.ImageUrl = "~/images/edit-10-xxl.png";
                            btnEdit.ToolTip  = "Click here to Edit the Product";
                            btnEdit.ID       = "ProductEdit~" + tab.Rows[cnt]["ProductId"].ToString();
                            btnEdit.Click   += new ImageClickEventHandler(btnEdit_Click);

                            cellEdit.Controls.Add(btnEdit);
                            row.Controls.Add(cellEdit);

                            TableCell cellDelete = new TableCell();

                            ImageButton btnDelete = new ImageButton();
                            btnDelete.Width         = 15;
                            btnDelete.Height        = 15;
                            btnDelete.ImageUrl      = "~/images/delete6.png";
                            btnDelete.ToolTip       = "Click here to Delete the Product";
                            btnDelete.ID            = "ProductDelete~" + tab.Rows[cnt]["ProductId"].ToString();
                            btnDelete.OnClientClick = "return confirm('Are you sure do you want to Delete?')";
                            btnDelete.Click        += new ImageClickEventHandler(btnDelete_Click);

                            cellDelete.Controls.Add(btnDelete);
                            row.Controls.Add(cellDelete);
                        }
                        else
                        {
                        }

                        tableProducts.Controls.Add(row);
                    }
                }
                else
                {
                    tableProducts.Rows.Clear();
                    tableProducts.BorderStyle = BorderStyle.None;

                    TableHeaderRow  row  = new TableHeaderRow();
                    TableHeaderCell cell = new TableHeaderCell();
                    cell.ColumnSpan = 5;
                    cell.Font.Bold  = true;
                    cell.ForeColor  = System.Drawing.Color.Red;
                    cell.Text       = "No Products Found";
                    row.Controls.Add(cell);

                    tableProducts.Controls.Add(row);
                }
            }
            catch
            {
                ClientScript.RegisterStartupScript(GetType(), "key", "<script>alert('Server Error - Check the Database Connectivity!!!')</script>");
            }
        }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        DataTable data;
        DataTable dataSheets = new DataTable();
        DataTable filterTable;
        DataTable ftable = new DataTable();
        int       count;
        object    missing = System.Reflection.Missing.Value;

        Microsoft.Office.Interop.Excel.Application excelObj = null;
        Microsoft.Office.Interop.Excel.Workbook    workbook = null;


        if (fileName != null && path != null)
        {
            if (fileExtension.Equals(".xlsx") || fileExtension.Equals(".xls"))
            {
                try
                {
                    excelObj = new Microsoft.Office.Interop.Excel.Application();
                    workbook = excelObj.Workbooks.Open(path + fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                    ArrayList sheetname = new ArrayList();

                    foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in workbook.Sheets)
                    {
                        //sheetname.Add(sheet.Name);
                        data = ReadExcelFile(sheet.Name, path + fileName);
                        dataSheets.Merge(data);
                    }

                    //data = ReadExcelFile("Sheet1", path + fileName);
                    filterTable = FilterFlightInfoData(dataSheets);
                    ftable      = filterTable;
                    //count = ftable.Rows.Count;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            else if (fileExtension.Equals(".csv"))
            {
                try
                {
                    string    SaveLocation = path + fileName;
                    DataTable csvData      = GetDataTableFromCSVFile(SaveLocation);
                    filterTable = FilterFlightInfoData(csvData);
                    ftable      = filterTable;
                    //count = filterTable.Rows.Count;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }

        try
        {
            count = ftable.Rows.Count;
            if (count > 0)
            {
                BLL.Flight.BulkInsertFlightInfo(ftable, getConstr.ConStrCMS);

                if (workbook != null)
                {
                    workbook.Close(false);
                    excelObj.Quit();

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelObj);
                }

                if (Directory.Exists(path))
                {
                    // Directory.Delete(SaveLocation);
                    File.Delete(path + "\\" + fileName);
                }

                string script = "<script>alert('File successfully imported!.')</" + "script>";
                ClientScript.RegisterStartupScript(GetType(), "Alert", script);

                RadGrid2.DataSource = GetFlightDetails();
                RadGrid2.Rebind();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }


        //if (FileUploadFlightInfo.HasFile)
        //{
        //    string extension = System.IO.Path.GetExtension(FileUploadFlightInfo.FileName); // extension file

        //    if (extension.Equals(".csv"))
        //    {
        //        try
        //        {

        //            string folderPath = Server.MapPath("~/Upload");

        //            //Check whether Directory (Folder) exists.
        //            if (!Directory.Exists(folderPath))
        //            {
        //                //If Directory (Folder) does not exists. Create it.
        //                Directory.CreateDirectory(folderPath);
        //            }

        //            string SaveLocation = folderPath + "\\" + FileUploadFlightInfo.FileName;
        //            //string SaveLocation = folderPath + Path.GetFileName(FileUploadFlightInfo.FileName);
        //            // FileUploadFlightInfo.SaveAs(SaveLocation);

        //            //Save the File to the Directory (Folder).
        //            FileUploadFlightInfo.SaveAs(SaveLocation);

        //            DataTable csvData = GetDataTableFromCSVFile(SaveLocation);
        //            DataTable filterTable = FilterFlightInfoData(csvData);
        //            int count = filterTable.Rows.Count;
        //            if(count > 0)
        //            {
        //                BLL.Flight.BulkInsertFlightInfo(filterTable, getConstr.ConStrCMS);

        //                //string script = "<script>CloseOnReload()</" + "script>";
        //                //ClientScript.RegisterStartupScript(this.GetType(), "CloseOnReload", script);

        //                if (Directory.Exists(folderPath))
        //                {
        //                    // Directory.Delete(SaveLocation);
        //                    File.Delete(SaveLocation);
        //                }

        //                string script = "<script>alert('File successfully imported!.')</" + "script>";
        //                ClientScript.RegisterStartupScript(GetType(), "Alert", script);

        //                RadGrid2.DataSource = GetFlightDetails();
        //                RadGrid2.Rebind();

        //            }



        //        }
        //        catch(Exception ex)
        //        {
        //            Console.WriteLine(ex);
        //        }
        //    }
        //    else
        //    {

        //    }
        //}
    }
コード例 #19
0
        protected void btnorder_Click1(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(_ConnStr);

            con.Open();

            SqlCommand cmd = new SqlCommand("update SQ set SQ_OrderStatus= 'Y' where SQ_Slno=@SQ_Slno;insert into Orders(ORD_SQ_Slno,ORD_SQ_RFQ_Number,ORD_SQ_RFQ_CreationDate,ORD_SQ_RFQ_OriginCountry,ORD_SQ_RFQ_DestinationCountry,ORD_SQ_RFQ_OriginAirport,ORD_SQ_RFQ_DestinationAirport,ORD_SQ_RFQ_NumberofPackages,ORD_SQ_RFQ_TotalGrwt,ORD_SQ_RFQ_TotalVolwt,ORD_SQ_RFQ_TotalChwt,ORD_SQ_RFQ_PickupAddress,ORD_SQ_RFQ_DeliveryAddress,ORD_SQ_RFQ_PickupDate,ORD_SQ_RFQ_ReqTT,ORD_SQ_RFQ_QuoteDueBy,ORD_SQ_RFQ_Commodity,ORD_SQ_RFQ_HandlingInfo,ORD_SQ_Company,ORD_SQ_OfferPrice,ORD_SQ_RFQ_ExpectedPrice,ORD_SellerCurrency,ORD_UserID,ORD_SQ_BuyerCurrency,ORD_SQ_RFQ_Company,ORD_Date,ORD_BuyerUserID) values (@SQ_Slno,@ORD_SQ_RFQ_Number,@ORD_SQ_RFQ_CreationDate,@ORD_SQ_RFQ_OriginCountry,@ORD_SQ_RFQ_DestinationCountry,@ORD_SQ_RFQ_OriginAirport,@ORD_SQ_RFQ_DestinationAirport,@ORD_SQ_RFQ_NumberofPackages,@ORD_SQ_RFQ_TotalGrwt,@ORD_SQ_RFQ_TotalVolwt,@ORD_SQ_RFQ_TotalChwt,@ORD_SQ_RFQ_PickupAddress,@ORD_SQ_RFQ_DeliveryAddress,@ORD_SQ_RFQ_PickupDate,@ORD_SQ_RFQ_ReqTT,@ORD_SQ_RFQ_QuoteDueBy,@ORD_SQ_RFQ_Commodity,@ORD_SQ_RFQ_HandlingInfo,@ORD_SQ_Company,@ORD_SQ_OfferPrice,@ORD_SQ_RFQ_ExpectedPrice,@ORD_SellerCurrency,@ORD_UserID,@ORD_SQ_BuyerCurrency,@ORD_SQ_RFQ_Company,'" + DateTime.Now + "','" + Session["M_Subscriber_UserID"] + "' )", con);

            cmd.Parameters.AddWithValue("@SQ_Slno", txtsqslno.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_Number", txtrfqnumber.Text);



            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_CreationDate", txtcreationdate.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_OriginCountry", txtorigincountry.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_DestinationCountry", txtdestinationcountry.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_OriginAirport", txtoriginairport.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_DestinationAirport", txtdestinationairport.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_NumberofPackages", txtnumberofpackages.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_TotalGrwt", txtgrossweight.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_TotalVolwt", txtvolumetricweight.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_TotalChwt", txtchargeableweight.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_PickupAddress", txtpickupaddress.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_DeliveryAddress", txtdeliveryaddress.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_PickupDate", txtpickupdate.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_ReqTT", txttransittime.Text);

            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_QuoteDueBy", txtquotedueby.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_Commodity", txtcommodity.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_HandlingInfo", txthandlinginfo.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_Company", txtsellercompany.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_OfferPrice", txtofferprice1.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_ExpectedPrice", txtexpectedprice1.Text);
            cmd.Parameters.AddWithValue("@ORD_SellerCurrency", txtsellercurrency.Text);
            cmd.Parameters.AddWithValue("@ORD_UserID", txtsellermail.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_BuyerCurrency", txtbuyercurrency.Text);
            cmd.Parameters.AddWithValue("@ORD_SQ_RFQ_Company", txtbuyercompany.Text);



            cmd.ExecuteNonQuery();
            GridViewQnb.EditIndex = -1;

            BindGridView();



            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('The order was placed successfully!!!');", true);

            //Mail Implementation
            SqlConnection con1 = new SqlConnection(_ConnStr);
            string        sellercompanyname = txtsellercompany.Text;
            SqlCommand    cmd1 = new SqlCommand("select ORD_Number,ORD_Date from Orders where ORD_SQ_Company = '" + sellercompanyname + "'", con);
            string        email = txtsellermail.Text;
            string        ordnumber, orddate;



            con1.Open();
            SqlDataReader dr = cmd1.ExecuteReader();

            while (dr.Read())
            {
                ordnumber = dr[0].ToString();
                orddate   = dr[1].ToString();
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress(Session["M_Subscriber_UserID"].ToString());
                msg.To.Add(email);
                msg.Subject    = "Order Confirmation for Air Freight against Transaction Number '" + txtrfqnumber.Text + "'";
                msg.IsBodyHtml = true;

                msg.Body = "Hi you have received a new order '" + ordnumber + "' " + "<br/>" +
                           "Dated '" + orddate + "' from '" + txtbuyercompany.Text + "' for Air Freight " + "<br/>" +
                           "From '" + txtoriginairport.Text + "' to '" + txtdestinationairport.Text + "' against" + "<br/>" +
                           "Transaction Number '" + txtrfqnumber.Text + "'";
                SmtpClient smtp = new SmtpClient();
                smtp.Host        = "smtp.gmail.com";
                smtp.Port        = 587;
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "niemysuru");
                smtp.EnableSsl   = true;
                smtp.Send(msg);
            }

            clear();
        }
コード例 #20
0
    protected void ButtNext_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            for (int i = 0; i < subjectids.Count; i++)
            {
                String insertQuery = "insert into feedback values('" + studid + "','" + subjectids[i] + "','" + facultyids[i] + "','" + semesterid + "','" + feedback_month + "')";
                cmd = new SqlCommand(insertQuery, con);
                cmd.ExecuteNonQuery();
                String     selectQuery1 = "SELECT MAX(id) FROM feedback";
                SqlCommand fComm        = new SqlCommand(selectQuery1, con);
                string     feedbackid   = fComm.ExecuteScalar().ToString().Replace(" ", "");
                feedbackids.Add(feedbackid);
            }
            con.Close();
            //////////

            /*con.Open();
             * String selectQuery1 = "SELECT MAX(id) FROM feedback";
             * SqlCommand fComm = new SqlCommand(selectQuery1, con);
             * string feedbackid = passComm.ExecuteScalar().ToString().Replace(" ", "");
             * con.Close();*/
            //////////
            int tempCount = 0;

            con.Open();
            foreach (GridViewRow row in GridView2.Rows)
            {
                string dropDownListText2 = ((DropDownList)row.FindControl("DropDownList2")).SelectedItem.Value;
                String insertQuery       = "insert into feedback_details values('" + feedbackids[0] + "','" + questionids[tempCount] + "','" + dropDownListText2 + "')";
                cmd = new SqlCommand(insertQuery, con);
                cmd.ExecuteNonQuery();

                string dropDownListText3 = ((DropDownList)
                                            row.FindControl("DropDownList3")).SelectedItem.Value;
                insertQuery = "insert into feedback_details values('" + feedbackids[1] + "','" + questionids[tempCount] + "','" + dropDownListText3 + "')";
                cmd         = new SqlCommand(insertQuery, con);
                cmd.ExecuteNonQuery();

                string dropDownListText4 = ((DropDownList)
                                            row.FindControl("DropDownList4")).SelectedItem.Value;
                insertQuery = "insert into feedback_details values('" + feedbackids[2] + "','" + questionids[tempCount] + "','" + dropDownListText4 + "')";
                cmd         = new SqlCommand(insertQuery, con);
                cmd.ExecuteNonQuery();

                string dropDownListText5 = ((DropDownList)
                                            row.FindControl("DropDownList5")).SelectedItem.Value;
                insertQuery = "insert into feedback_details values('" + feedbackids[3] + "','" + questionids[tempCount] + "','" + dropDownListText5 + "')";
                cmd         = new SqlCommand(insertQuery, con);
                cmd.ExecuteNonQuery();

                tempCount++;
            }
            con.Close();
        }
        catch (Exception e8)
        {
            ClientScript.RegisterStartupScript(GetType(), "Onload", "alert(" + e8.Message + ")", true);
        }
    }
コード例 #21
0
 void myConnection_InfoMessage(object sender, SqlInfoMessageEventArgs e)
 {
     ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + e.Message + "');", true);
 }
コード例 #22
0
    protected void btnPreview_Click(object sender, EventArgs e)
    {
        string strSelect = "";

        if (ddlReportName.SelectedItem.Text == "Competitor Sales")
        {
            strSelect = "Select * from View_TRANSACTIONPAPER where TRADATE between '" + txtDateFrom.Text + "' and '" + txtDateTo.Text + "'";

            if (ddlPaperName.SelectedItem.Text != "--Select--")
            {
                if (ddlPaperName.SelectedItem.Text == "Prothom Alo")
                {
                    strSelect = strSelect + "AND ( PAPERNAME like'%Prothom Alo%') ";
                }
                else
                {
                    strSelect = strSelect + "AND PAPERNAME='" + ddlPaperName.SelectedItem.Text + "'";
                }
            }

            strSelect = strSelect + "ORDER BY sortOrder asc";
        }
        else
        {
            strSelect = "Select * from CompetitorSummary where TRADATE between '" + txtDateFrom.Text + "' and '" + txtDateTo.Text + "'";
        }


        if (ddlReportName.SelectedItem.Text == "Competitor Sales" && ddlPaperName.SelectedItem.Text == "--Select--")
        {
            DataSet ds = new DataSet();
            ds = dataProvider.getDataSet(strSelect, "View_TRANSACTIONPAPER");
            report.Load(Server.MapPath("Report\\CompetitorInfo.rpt"));
            report.SetDataSource(ds);
            report.SetDatabaseLogon("abomuser", "erp", "192.168.10.75", "ALOCIR");

            if (ddlExportType.SelectedItem.Text == "Pdf")
            {
                report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath("Report/CompetitorInfo.pdf"));
                ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report/CompetitorInfo.pdf');popup.focus();", true);
            }
            else if (ddlExportType.SelectedItem.Text == "Excel")
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Page.Response, false, "CompetitorInfo");
            }
            else
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.RichText, Page.Response, false, "CompetitorInfo");
            }
        }
        else if (ddlReportName.SelectedItem.Text == "Competitor Summary" && ddlPaperName.SelectedItem.Text == "--Select--")
        {
            DataSet ds = new DataSet();
            ds = dataProvider.getDataSet(strSelect, "CompetitorSummary");
            report.Load(Server.MapPath("Report\\CompetitorSummary.rpt"));
            report.SetDataSource(ds);
            report.SetDatabaseLogon("abomuser", "erp", "192.168.10.75", "ALOCIR");

            if (ddlExportType.SelectedItem.Text == "Pdf")
            {
                report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath("Report/CompetitorSummary.pdf"));
                ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report/CompetitorSummary.pdf');popup.focus();", true);
            }
            else if (ddlExportType.SelectedItem.Text == "Excel")
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Page.Response, false, "CompetitorSummary");
            }
            else
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.RichText, Page.Response, false, "CompetitorSummary");
            }
        }
        else
        {
            DataSet ds = new DataSet();
            ds = dataProvider.getDataSet(strSelect, "View_TRANSACTIONPAPER");
            report.Load(Server.MapPath("Report\\CompetitorInfoPalo.rpt"));
            report.SetDataSource(ds);
            report.SetDatabaseLogon("abomuser", "erp", "192.168.10.75", "ALOCIR");

            if (ddlExportType.SelectedItem.Text == "Pdf")
            {
                report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath("Report/CompetitorInfoPalo.pdf"));
                ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report/CompetitorInfoPalo.pdf');popup.focus();", true);
            }
            else if (ddlExportType.SelectedItem.Text == "Excel")
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Page.Response, false, "CompetitorInfoPalo");
            }
            else
            {
                report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.RichText, Page.Response, false, "CompetitorInfoPalo");
            }
        }
    }
コード例 #23
0
ファイル: server.aspx.cs プロジェクト: macntouch/clonedeploy
    protected void btnUpdateSettings_OnClick(object sender, EventArgs e)
    {
        RequiresAuthorization(Authorizations.UpdateAdmin);
        if (!ValidateSettings())
        {
            return;
        }
        var listSettings = new List <Models.Setting>
        {
            new Models.Setting {
                Name = "Server IP", Value = txtIP.Text, Id = Setting.GetSetting("Server IP").Id
            },
            new Models.Setting {
                Name = "Web Server Port", Value = txtPort.Text, Id = Setting.GetSetting("Web Server Port").Id
            },
            new Models.Setting {
                Name = "Tftp Path", Value = txtTFTPPath.Text, Id = Setting.GetSetting("Tftp Path").Id
            },
            new Models.Setting {
                Name = "Default Computer View", Value = ddlComputerView.Text, Id = Setting.GetSetting("Default Computer View").Id
            },
            new Models.Setting {
                Name = "Web Path", Value = txtWebService.Text, Id = Setting.GetSetting("Web Path").Id
            }
        };

        var newBootMenu  = false;
        var newClientIso = false;

        if (Setting.UpdateSetting(listSettings))
        {
            EndUserMessage = "Successfully Updated Settings";
            if ((string)ViewState["serverIP"] != txtIP.Text)
            {
                newBootMenu  = true;
                newClientIso = true;
            }
            if ((string)ViewState["serverPort"] != txtPort.Text)
            {
                newBootMenu  = true;
                newClientIso = true;
            }
            if ((string)ViewState["servicePath"] != ParameterReplace.Between(txtWebService.Text))
            {
                newBootMenu  = true;
                newClientIso = true;
            }
        }
        else
        {
            EndUserMessage = "Could Not Update Settings";
        }

        if (!newBootMenu)
        {
            return;
        }


        lblTitle.Text =
            "Your Settings Changes Require A New PXE Boot File Be Created.  <br>Go There Now?";
        if (newClientIso)
        {
            lblClientISO.Text = "The Client ISO Must Also Be Updated.";
        }
        ClientScript.RegisterStartupScript(GetType(), "modalscript",
                                           "$(function() {  var menuTop = document.getElementById('confirmbox'),body = document.body;classie.toggle(menuTop, 'confirm-box-outer-open'); });",
                                           true);
        Session.Remove("Message");
    }
コード例 #24
0
    protected void GradeAssignment(string path, string userId, string assignmentID, string userName, string assignmentName)
    {
        ///////////////////
        string          sampleInput = null, sampleOutput = null;
        DataTable       dt         = null;
        MySqlConnection connection = new MySqlConnection(connectionString);

        connection.Open();
        try
        {
            MySqlCommand comm = connection.CreateCommand();
            comm.CommandText = "SELECT assignmentId,sampleInput,sampleOutput FROM testcases where assignmentId=@assignmentId";
            comm.Parameters.AddWithValue("@assignmentId", assignID);
            MySqlDataAdapter adap = new MySqlDataAdapter(comm);
            DataSet          ds   = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception ex)
        {
            Response.Redirect("~/Error");
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
        if (dt.Rows.Count == 0)
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "Error", "<script language='javascript'>alert('Submission Failed. Please retry.')</script>");
            return;
        }
        double  sum = 0;
        int     numberOfTestcases = 0;
        Literal resultHTML        = new Literal();
        string  htmlSample        = "";

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string output = "";
            sampleInput  = dt.Rows[i][1].ToString();
            sampleOutput = dt.Rows[i][2].ToString();
            string exeOutput = "";
            if (sampleInput != null && sampleInput != "")
            {
                exeOutput = CheckAssignmentZip(userId, assignmentID, assignmentName, ToStream(sampleInput));

                if (exeOutput == sampleOutput)
                {
                    output = "100%";
                    sum    = sum + 100;
                    numberOfTestcases++;
                }
                else
                {
                    output = "test case failed..!!";
                    sum    = sum + 0;
                    numberOfTestcases++;
                }
            }
            string resultInnerHTML = "<hr /><div class='container'>" +
                                     "<div class='container' style='width: 100%;'>" +
                                     "<div class='panel panel-default'>" +
                                     "<div class='panel-heading' style='align-content: center; font-weight: bold'>Test Case " + (i + 1) + "</div>" +
                                     "<div class='panel-body'>" +
                                     "<h4>" + output + "</h4>" +
                                     "<asp:LinkButton runat='server' title='Sample Input' data-toggle='popover' data-trigger='hover' data-content='" + sampleInput + "'>Sample Input</asp:LinkButton><br />" +
                                     "<asp:LinkButton runat='server' title='Sample Output' data-toggle='popover' data-trigger='hover' data-content='" + sampleOutput + "'>Sample Output</asp:LinkButton><br />" +
                                     "<asp:LinkButton runat='server' title='Executed Output' data-toggle='popover' data-trigger='hover' data-content='" + exeOutput + "'>Executed Output</asp:LinkButton><br />" +
                                     "</div></div></div></div>";
            htmlSample = htmlSample + resultInnerHTML;
        }
        resultHTML.Text = htmlSample;
        testcasePHMain.Controls.Add(resultHTML);

        MySqlConnection conn = new MySqlConnection(connectionString);

        conn.Open();
        string maxpoints = "";

        try
        {
            MySqlCommand mysqlcmd = conn.CreateCommand();
            mysqlcmd.CommandText = "SELECT points FROM assignments WHERE assignmentId=@assignmentId";
            mysqlcmd.Parameters.AddWithValue("assignmentId", assignmentID);
            maxpoints = mysqlcmd.ExecuteScalar().ToString();
        }
        catch (Exception ex)
        {
            Response.Redirect("~/Error");
        }
        finally
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
        double percentage = (((sum / numberOfTestcases) / 100) * Convert.ToInt32(maxpoints));

        percentLBL.Text  = percentage.ToString() + " out of " + maxpoints;
        outputPH.Visible = true;
        /////////////////////////////
        var             result = 0;
        MySqlConnection conn1  = new MySqlConnection(connectionString);

        conn1.Open();
        try
        {
            MySqlCommand mysqlcmd = conn1.CreateCommand();
            mysqlcmd.CommandText = "SELECT count(*) FROM studentassignments WHERE assignmentId=@assignmentId AND studentId=@userId";
            mysqlcmd.Parameters.AddWithValue("assignmentId", assignmentID);
            mysqlcmd.Parameters.AddWithValue("userId", userId);
            result = Convert.ToInt32(mysqlcmd.ExecuteScalar());
        }
        catch (Exception ex)
        {
            Response.Redirect("~/Error");
        }
        finally
        {
            if (conn1.State == ConnectionState.Open)
            {
                conn1.Close();
            }
        }

        if (result <= 0)
        {
            MySqlConnection conn2 = new MySqlConnection(connectionString);
            MySqlCommand    cmd;
            conn2.Open();
            try
            {
                cmd             = conn2.CreateCommand();
                cmd.CommandText = "INSERT INTO studentassignments(assignmentId,studentId,points,comments,zipFileName,filePath) VALUES(@assignmentId,@studentId,@points,@comments,@zipFileName,@filePath)";
                cmd.Parameters.AddWithValue("@assignmentID", assignID);
                cmd.Parameters.AddWithValue("@studentId", userID);
                cmd.Parameters.AddWithValue("@points", (int)percentage);
                cmd.Parameters.AddWithValue("@comments", "");
                cmd.Parameters.AddWithValue("@zipFileName", userID + "_" + assignID + ".zip");
                cmd.Parameters.AddWithValue("@filePath", path);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "Error", "<script language='javascript'>alert('Submission Failed. Please retry.')</script>");
                Response.Redirect("~/Error");
            }
            finally
            {
                if (conn2.State == ConnectionState.Open)
                {
                    conn2.Close();
                }
            }
        }
        if (result > 0)
        {
            MySqlConnection conn3 = new MySqlConnection(connectionString);
            MySqlCommand    cmd;
            conn3.Open();
            try
            {
                cmd             = conn3.CreateCommand();
                cmd.CommandText = "UPDATE studentassignments SET points=@points,comments=@comments,zipFileName=@zipFileName,filePath=@filePath where assignmentId=@assignmentID and studentId=@studentId";
                cmd.Parameters.AddWithValue("@assignmentID", assignID);
                cmd.Parameters.AddWithValue("@studentId", userID);
                cmd.Parameters.AddWithValue("@points", (int)percentage);
                cmd.Parameters.AddWithValue("@comments", "");
                cmd.Parameters.AddWithValue("@zipFileName", userID + "_" + assignID + ".zip");
                cmd.Parameters.AddWithValue("@filePath", path);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "Error", "<script language='javascript'>alert('Submission Failed. Please retry.')</script>");
                Response.Redirect("~/Error");
            }
            finally
            {
                if (conn3.State == ConnectionState.Open)
                {
                    conn3.Close();
                }
                LoadStudentGridView();
                checkAssignmentSubmission();
            }
        }
    }
コード例 #25
0
        protected void gvFeesCategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            FeesCategoryBL objFeesBl = new FeesCategoryBL();

            try
            {
                ViewState["FeesCategoryMID"] = Convert.ToInt32(e.CommandArgument.ToString());
                if (e.CommandName.ToString() == "Edit1")
                {
                    ApplicationResult objResultsEdit = new ApplicationResult();
                    objResultsEdit = objFeesBl.FeesCategory_Select(Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));

                    if (objResultsEdit != null)
                    {
                        if (objResultsEdit.resultDT.Rows.Count > 0)
                        {
                            txtFeesCategoryName.Text          = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEESNAME].ToString();
                            rblFeeType.SelectedValue          = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEESTYPE].ToString();
                            ddlOutstandingMonth.SelectedValue = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_OutstandingMonth].ToString();
                            txtAbbreviation.Text = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEEABBREVIATION].ToString();
                            ddlFeeGroup.Text     = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEEGROUPID].ToString();
                            ViewState["Mode"]    = "Edit";
                            PanelGrid_VisibilityMode(2);
                        }
                    }
                }

                if (e.CommandName.ToString() == "Delete1")
                {
                    Controls objControls = new Controls();
                    //objControls.EnableControls(Master.FindControl("ContentPlaceHolder1"));
                    ApplicationResult objDelete = new ApplicationResult();

                    objDelete = objFeesBl.Validate_FeesCategory_Delete(Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                    if (objDelete != null)
                    {
                        if (objDelete.resultDT.Rows.Count > 0)
                        {
                            if (Convert.ToInt32(objDelete.resultDT.Rows[0]["FeesCategoryMID"]) == Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()))
                            {
                                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('There are ClasseTemplate(s) associated with this FeeCategory. To delete this FeeCategory you need to delete ClasseTemplate(s) first');</script>");
                                goto Exit;
                            }
                        }
                    }
                    ApplicationResult objResultsDelete = new ApplicationResult();

                    objResultsDelete = objFeesBl.FeesCategory_Delete(Convert.ToInt32(e.CommandArgument.ToString()));
                    if (objResultsDelete.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                        ClearAll();
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Fee Category deleted successfully.');</script>");
                        GridDataBind();
                        PanelGrid_VisibilityMode(1);
                    }
                }
                Exit :;
            }
            catch (Exception ex)
            {
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
        }
コード例 #26
0
 protected void btnClose_Click(object sender, EventArgs e)
 {
     ClientScript.RegisterStartupScript(GetType(), "Load", "<script type='text/javascript'>parent.emailwindow.close(); parent.GetCurrentTime()</script>");
 }
コード例 #27
0
 protected void btRep_Click(object sender, EventArgs e)
 {
     clienteID = Convert.ToInt32((sender as LinkButton).CommandArgument);
     ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "abrirVentana('Reportes/ReporteCliente.aspx?id=" + clienteID + "')", true);
 }
コード例 #28
0
        //click event to insert new product and to update existing product
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            BLL obj = new BLL();

            try
            {
                if (btnAdd.Text == "Add")
                {
                    if (dropdownlistCategories.SelectedIndex > 0)
                    {
                        if (obj.CheckProductName(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value))
                        {
                            string photoName = System.IO.Path.GetFileName(fileuploadPhoto.PostedFile.FileName);

                            int    index = photoName.LastIndexOf('.');
                            string ext   = photoName.Substring(index + 1);

                            string photoPath = null;
                            string dbPath    = null;

                            photoPath = Server.MapPath("~/Company/Photos/" + txtProductName.Value + "." + ext);
                            fileuploadPhoto.PostedFile.SaveAs(photoPath);
                            dbPath = @"/Company/Photos/" + txtProductName.Value + "." + ext;

                            if (txtSoldQuantity.Text.Equals(""))
                            {
                                txtSoldQuantity.Text = "0";
                                txtProfit.Value      = "0";
                            }

                            obj.InsertProduct(int.Parse(dropdownlistCategories.SelectedValue.ToString()), txtProductName.Value, txtDescription.Value, float.Parse(txtCost.Value), dbPath,
                                              float.Parse(txtInvestment.Value), int.Parse(txtSoldQuantity.Text), txtProfit.Value, DateTime.Now, float.Parse(txtInvestmentperProduct.Text), int.Parse(txtQuantity.Text));
                            ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('New Product Added Successfully')</script>");
                            ClearTextboxes();
                            dropdownlistCategories_SelectedIndexChanged(sender, e);
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Product Name Exists!!!')</script>");
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Select Category!!!')</script>");
                    }
                }
                else if (btnAdd.Text == "Update")
                {
                    if (dropdownlistCategories.SelectedIndex > 0)
                    {
                        if (Session["productName"].Equals(txtProductName.Value))
                        {
                            if (fileuploadPhoto.Enabled)
                            {
                                File.Delete(Server.MapPath(Session["oldDBPath"].ToString()));
                                string photoName = System.IO.Path.GetFileName(fileuploadPhoto.PostedFile.FileName);

                                int    index = photoName.LastIndexOf('.');
                                string ext   = photoName.Substring(index + 1);

                                string phtotPath = Server.MapPath("/Company/Photos/" + Session["productName"] + "." + ext);
                                fileuploadPhoto.PostedFile.SaveAs(phtotPath);

                                string dbPath = "~/Company/Photos/" + Session["productName"] + "." + ext;

                                if (txtSoldQuantity.Text.Equals(""))
                                {
                                    txtSoldQuantity.Text = "0";
                                    txtProfit.Value      = "0";
                                }

                                obj.UpdateProduct(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value, txtDescription.Value, float.Parse(txtCost.Value), dbPath,
                                                  float.Parse(txtInvestment.Value), int.Parse(txtSoldQuantity.Text), txtProfit.Value, DateTime.Now, int.Parse(Session["ProductId"].ToString()), float.Parse(txtInvestmentperProduct.Text), int.Parse(txtQuantity.Text));
                            }
                            else
                            {
                                obj.UpdateProduct(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value, txtDescription.Value, float.Parse(txtCost.Value), Session["oldDBPath"].ToString(),
                                                  float.Parse(txtInvestment.Value), int.Parse(txtSoldQuantity.Text), txtProfit.Value, DateTime.Now, int.Parse(Session["ProductId"].ToString()), float.Parse(txtInvestmentperProduct.Text), int.Parse(txtQuantity.Text));
                            }

                            btnAdd.Text = "Add";
                            dropdownlistCategories_SelectedIndexChanged(sender, e);
                            ClearTextboxes();
                            ClientScript.RegisterStartupScript(this.GetType(), "Key", "<script>alert('Product Updated Successfully')</script>");
                        }
                        else
                        {
                            if (obj.CheckProductName(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value))
                            {
                                if (fileuploadPhoto.Enabled)
                                {
                                    File.Delete(Server.MapPath(Session["oldDBPath"].ToString()));
                                    string photoName = System.IO.Path.GetFileName(fileuploadPhoto.PostedFile.FileName);

                                    int    index = photoName.LastIndexOf('.');
                                    string ext   = photoName.Substring(index + 1);

                                    string phtotPath = Server.MapPath("/Company/Photos/" + txtProductName.Value + "." + ext);
                                    fileuploadPhoto.PostedFile.SaveAs(phtotPath);

                                    string dbPath = "~/Company/Photos/" + txtProductName.Value + "." + ext;

                                    if (txtSoldQuantity.Text.Equals(""))
                                    {
                                        txtSoldQuantity.Text = "0";
                                        txtProfit.Value      = "0";
                                    }


                                    obj.UpdateProduct(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value, txtDescription.Value, float.Parse(txtCost.Value), dbPath,
                                                      float.Parse(txtInvestment.Value), int.Parse(txtSoldQuantity.Text), txtProfit.Value, DateTime.Now, int.Parse(Session["ProductId"].ToString()), float.Parse(txtInvestmentperProduct.Text), int.Parse(txtQuantity.Text));
                                }
                                else
                                {
                                    obj.UpdateProduct(int.Parse(dropdownlistCategories.SelectedValue), txtProductName.Value, txtDescription.Value, float.Parse(txtCost.Value), Session["oldDBPath"].ToString(),
                                                      float.Parse(txtInvestment.Value), int.Parse(txtSoldQuantity.Text), txtProfit.Value, DateTime.Now, int.Parse(Session["ProductId"].ToString()), float.Parse(txtInvestmentperProduct.Text), int.Parse(txtQuantity.Text));
                                }

                                btnAdd.Text = "Add";
                                dropdownlistCategories_SelectedIndexChanged(sender, e);
                                ClearTextboxes();
                                ClientScript.RegisterStartupScript(this.GetType(), "Key", "<script>alert('Product Updated Successfully')</script>");
                            }
                            else
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Product Name Exists!!!')</script>");
                            }
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Select Category!!!')</script>");
                    }
                }
            }
            catch
            {
                ClientScript.RegisterStartupScript(GetType(), "key", "<script>alert('Server Error - Check the Database Connectivity!!!')</script>");
            }
        }
コード例 #29
0
        protected void btEli_Click(object sender, EventArgs e)
        {
            try {
                //ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "eliminar()", true);
                using (MySqlConnection sqlCOn = new MySqlConnection("server=localhost; database=hotel; Uid=root; pwd=; SslMode = none"))
                {
                    //contenedor.Text = "" + Convert.ToInt32((sender as LinkButton).CommandArgument);
                    //if (algo.Text == "eliminar" && !(contenedor.Text==""))
                    //{
                    // contenedor.Text = "" + Convert.ToInt32((sender as LinkButton).CommandArgument)
                    clienteID = Convert.ToInt32((sender as LinkButton).CommandArgument);
                    string idhabitacion = "";

                    sqlCOn.Open();
                    MySqlCommand hmd = sqlCOn.CreateCommand();
                    hmd.CommandType = CommandType.Text;
                    hmd.CommandText = "SELECT * FROM cliente WHERE idcliente=" + clienteID + "";
                    hmd.ExecuteNonQuery();
                    MySqlDataReader dr = hmd.ExecuteReader();
                    if (dr.Read() == true)
                    {
                        idhabitacion = dr["idhabitacion"].ToString();
                    }
                    sqlCOn.Close();

                    sqlCOn.Open();
                    MySqlCommand cmd = sqlCOn.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "delete from cliente WHERE idcliente=" + clienteID + "";
                    int i = cmd.ExecuteNonQuery();
                    sqlCOn.Close();
                    if (i > 0)
                    {
                        sqlCOn.Open();
                        MySqlCommand dmd = sqlCOn.CreateCommand();
                        dmd.CommandType = CommandType.Text;
                        dmd.CommandText = "UPDATE habitacion SET estado=false WHERE idhabitacion=" + idhabitacion + "";
                        dmd.ExecuteNonQuery();
                        sqlCOn.Close();

                        sqlCOn.Open();
                        MySqlCommand ucd = sqlCOn.CreateCommand();
                        ucd.CommandType = CommandType.Text;
                        ucd.CommandText = "DELETE FROM usuario WHERE idcliente=" + clienteID;
                        ucd.ExecuteNonQuery();
                        sqlCOn.Close();

                        ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "datosCorrectos()", true);
                    }
                    else
                    {
                        sqlCOn.Close();
                        ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "datosIncorrectos()", true);
                    }
                    sqlCOn.Close();
                    //}
                }
            } catch (Exception x) {
                ClientScript.RegisterStartupScript(this.GetType(), "ramdomtext", "datosIncorrectos()", true);
            }
        }
コード例 #30
0
ファイル: add.aspx.cs プロジェクト: Cosmin3/ToyStore
        protected void Button1_Click(object sender, EventArgs e)
        {
            bool             add;
            List <ArrayList> products = web.getProducts();
            int nameAp = 0;
            int codAp  = 0;

            foreach (ArrayList product in products)
            {
                if (Convert.ToString(product[1]) == TextBox2.Text)
                {
                    nameAp++;
                }
                if (Convert.ToString(product[0]) == TextBox1.Text)
                {
                    codAp++;
                }
            }
            if (codAp > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Code already in the database " + "');", true);
            }
            else
            {
                if (nameAp > 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Name already in the database " + "');", true);
                }
                else
                {
                    int i;
                    if (!int.TryParse(TextBox7.Text, out i))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "The Quantity must be an integer" + "');", true);
                    }
                    else
                    {
                        decimal d;
                        if (!decimal.TryParse(TextBox8.Text, out d) || !decimal.TryParse(TextBox9.Text, out d))
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "The Prices must be decimal" + "');", true);
                        }
                        else
                        {
                            add = web.AddToy(TextBox1.Text, TextBox2.Text, DropDownList1.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, Convert.ToInt32(TextBox7.Text), Convert.ToDouble(TextBox8.Text), Convert.ToDouble(TextBox9.Text));
                            if (add)
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Produs adaugat " + "');", true);
                                if ((string)Session["LoggedUser"] == "admin")
                                {
                                    Response.Redirect("padmin.aspx");
                                }
                                else
                                {
                                    Response.Redirect("productsEmployee.aspx");
                                }
                            }
                            else
                            {
                                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Eroare in timpul adaugarii" + "');", true);
                            }
                        }
                    }
                }
            }
        }