예제 #1
0
        protected void ddl_Ports_SelectedIndexChanged(object sender, EventArgs e)
        {
            CMACGMEntities1 db       = new CMACGMEntities1();
            string          portName = ddl_Ports.SelectedValue;

            //find port id
            CMACGM.Port selectedPort = new CMACGM.Port();
            if (db.Ports.Any(a => a.Name == portName))
            {
                selectedPort = db.Ports.Where(a => a.Name == portName).First();
            }
            if (selectedPort != null)
            {
                BindData(selectedPort.id);
            }
        }
예제 #2
0
        protected void BindData(int PortID)
        {
            CMACGMEntities1 db = new CMACGMEntities1();

            if (db.Queries.Any(a => a.PortID == PortID))
            {
                var queries = db.Queries.Where(a => a.PortID == PortID).Select(a => new { a.id, a.Port.Name, a.LaraPartnerCode, a.BookingReference, a.Voyage, a.AttachedFilePath }).ToList();
                rptr_queries.DataSource = queries;
                rptr_queries.DataBind();
            }
            else
            {
                rptr_queries.DataSource = null;
                rptr_queries.DataBind();
            }
        }
예제 #3
0
        protected void lb_downloadFile_Click(object sender, EventArgs e)
        {
            CMACGMEntities1 db = new CMACGMEntities1();


            LinkButton lb_download = (LinkButton)sender;
            int        queryID     = Convert.ToInt32(lb_download.CommandName);
            Query      query       = db.Queries.Where(a => a.id == queryID).First();
            string     fileName    = query.AttachedFilePath;
            string     portName    = query.Port.Name;

            // find path of this query id to download
            if (fileName != "")
            {
                Response.ContentType = "application/octet-stream";
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
                string filePath = CargoUtil.filePath + portName + "/" + fileName;
                Response.TransmitFile(filePath);
                Response.End();
            }
        }
예제 #4
0
        protected void FillData()
        {
            CMACGMEntities1 db = new CMACGMEntities1();

            if (db.Ports.Any())
            {
                var ports   = db.Ports.ToList();
                var newData = from x in ports select new { x.id, x.Name, x.Location, Port = String.Format("{0} {1}", x.Name, x.Location) };
                ddl_Ports.DataSource     = newData;
                ddl_Ports.DataTextField  = "Port";
                ddl_Ports.DataValueField = "Name";
                ddl_Ports.DataBind();
                ddl_Ports.Items.Insert(0, new ListItem("--Select Port--", "0"));
                ddl_Ports.SelectedIndex = 0;
            }
            else
            {
                ddl_Ports.DataSource = null;
                ddl_Ports.DataBind();
            }
        }
예제 #5
0
        protected void btn_Register_Click(object sender, EventArgs e)
        {
            CMACGMEntities1 db      = new CMACGMEntities1();
            var             manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var             user    = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text
            };
            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var manage        = manager.FindByEmail(Email.Text);

            if (manage == null)
            {
                IdentityResult result = manager.Create(user, Password.Text);
                if (result.Succeeded)
                {
                    AdminProfile newAdmin = new AdminProfile();
                    signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                    newAdmin.FirstName    = tb_firstName.Text;
                    newAdmin.FirstName    = tb_lastName.Text;
                    newAdmin.AspNetUserId = user.Id;
                    db.AdminProfiles.Add(newAdmin);
                    db.SaveChanges();

                    //IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                    Response.Redirect("~/Login.aspx");
                }
                else
                {
                    ErrorMessage.Text = result.Errors.FirstOrDefault();
                }
            }
            else
            {
                ErrorMessage.Text = "Provided email address is already registered. Please Enter a different email address.";
            }
        }
예제 #6
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            CMACGMEntities1 db = new CMACGMEntities1();
            //check validations
            Query newData = new Query();

            if (tb_BookingRef.Text != "")
            {
                newData.BookingReference = tb_BookingRef.Text;
            }
            if (tb_LaraPartnerCode.Text != "")
            {
                newData.LaraPartnerCode = tb_LaraPartnerCode.Text;
            }
            if (tb_Voyage.Text != "")
            {
                newData.Voyage = tb_Voyage.Text;
            }
            if (ddl_Ports.SelectedIndex != 0 && ddl_Ports.SelectedValue != "")
            {
                //find port id
                if (tb_BookingRef.Text != "" && tb_LaraPartnerCode.Text != "" && tb_Voyage.Text != "" && fileUploader.HasFile)
                {
                    CMACGM.Port selectedPort = new CMACGM.Port();
                    if (db.Ports.Any(a => a.Name == ddl_Ports.SelectedValue))
                    {
                        selectedPort = db.Ports.Where(a => a.Name == ddl_Ports.SelectedValue).First();
                    }
                    newData.Port = selectedPort;

                    if (fileUploader.HasFile)
                    {
                        string Extension = Path.GetExtension(fileUploader.PostedFile.FileName);
                        if (Extension == ".png" && Extension == ".jpeg" && Extension == ".jpg" && Extension == ".txt" && Extension == ".TXT" && Extension == ".doc" && Extension == ".docx")
                        {
                            try
                            {
                                string filename = Path.GetFileName(fileUploader.FileName);
                                string filePath = CargoUtil.filePath + ddl_Ports.SelectedValue + "/";
                                bool   exists   = System.IO.Directory.Exists(filePath);
                                if (!exists)
                                {
                                    System.IO.Directory.CreateDirectory(filePath);
                                }
                                fileUploader.SaveAs(filePath + filename);
                                newData.AttachedFilePath = filename;
                                lbl_UploadStatus.Visible = true;
                                ClearFields();
                            }
                            catch (Exception ex)
                            {
                                ScriptManager.RegisterStartupScript(this, typeof(Page), "text", "alert('Upload status: The file could not be uploaded. Please try again');", true);
                            }
                        }
                    }
                    try
                    {
                        newData.UserID = 1.ToString();
                        db.Queries.Add(newData);
                        db.SaveChanges();
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "text", "alert('Form submitted successfully!');", true);
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "text", "alert('Something went wrong , Please try again!');", true);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "text", "alert('Please Select Port');", true);
            }
        }