Example #1
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        //FilterRefreash();
        lblMessage.Text = "";
        string    strLocalPath = FileUploader.PostedFile.FileName;
        string    FileName     = "";
        DataTable dt           = new DataTable();

        dt = objUploadFilesize.Get_Module_FileUpload("INF_");
        string datasize = dt.Rows[0]["Size_KB"].ToString();

        if (HiddenFlag.Value == "Add")
        {
            if (FileUploader.HasFile)
            {
                if (FileUploader.PostedFile.ContentLength < Int32.Parse(dt.Rows[0]["Size_KB"].ToString()) * 1024)
                {
                    //FileName = System.Guid.NewGuid() + Path.GetExtension(strLocalPath);
                    FileName = txtVesselShortName.Text + "_" + DateTime.Now.ToString("dd-MM-yyyy HH.mm.ss") + "_" + Path.GetFileName(strLocalPath);

                    int Retval = objBLL.INSERT_New_Vessel(null, txtVessel.Text, txtVesselShortName.Text, txtEmailID.Text, UDFLib.ConvertToInteger(ddlFleet_AddVessel.SelectedValue),
                                                          UDFLib.ConvertToInteger(ddlVesselManager.SelectedValue), UDFLib.ConvertDateToNull(dtTakeoverDate.Text),
                                                          UDFLib.ConvertDateToNull(dtHandoverDate.Text), UDFLib.ConvertIntegerToNull(ddlVesselFlage_AddVessel.SelectedValue), Convert.ToInt32(Session["UserID"].ToString()),
                                                          UDFLib.ConvertDecimalToNull(txtMinimumCTM.Text), chkSyncEnable.Checked == true ? "-1" : "0", FileName, UDFLib.ConvertIntegerToNull(ddlvessel_AddType.SelectedValue));

                    if (Retval != 0)
                    {
                        objBLL.INSERT_New_SURVEY_VesselDetails(Retval.ToString(), txtCallSign.Text, txtIMONo.Text, txtLength.Text, txtMMSI.Text, UDFLib.ConvertDateToNull(txtYearBuilt.Text));
                    }

                    FileUploader.PostedFile.SaveAs(Server.MapPath("~/Uploads/MEPowerCurve/" + FileName));
                    BindVesselGrid();
                }
                else
                {
                    lblMessage.Text = datasize + " KB File size exceeds maximum limit";
                }
            }
            else
            {
                FileName = txtVesselShortName.Text + "_" + DateTime.Now.ToString("dd-MM-yyyy HH.mm.ss") + "_" + Path.GetFileName(strLocalPath);
                int Retval = objBLL.INSERT_New_Vessel(null, txtVessel.Text, txtVesselShortName.Text, txtEmailID.Text, UDFLib.ConvertToInteger(ddlFleet_AddVessel.SelectedValue),
                                                      UDFLib.ConvertToInteger(ddlVesselManager.SelectedValue), UDFLib.ConvertDateToNull(dtTakeoverDate.Text),
                                                      UDFLib.ConvertDateToNull(dtHandoverDate.Text), UDFLib.ConvertIntegerToNull(ddlVesselFlage_AddVessel.SelectedValue), Convert.ToInt32(Session["UserID"].ToString()),
                                                      UDFLib.ConvertDecimalToNull(txtMinimumCTM.Text), chkSyncEnable.Checked == true ? "-1" : "0", null, UDFLib.ConvertIntegerToNull(ddlvessel_AddType.SelectedValue));


                if (Retval != 0)
                {
                    objBLL.INSERT_New_SURVEY_VesselDetails(Retval.ToString(), txtCallSign.Text, txtIMONo.Text, txtLength.Text, txtMMSI.Text, UDFLib.ConvertDateToNull(txtYearBuilt.Text));
                }
            }
            BindVesselGrid();

            string hidemodal = String.Format("hideModal('dvAddNewVessel')");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true);
        }
        else
        if (FileUploader.HasFile)
        {
            if (FileUploader.PostedFile.ContentLength < Int32.Parse(dt.Rows[0]["Size_KB"].ToString()) * 1024)
            {
                FileName = txtVesselShortName.Text + "_" + DateTime.Now.ToString("dd-MM-yyyy HH.mm.ss") + "_" + Path.GetFileName(strLocalPath);

                int Retval = objBLL.UPDATE_Vessel(Convert.ToInt32(txtVesselID.Text), null, txtVessel.Text, txtVesselShortName.Text, txtEmailID.Text, Convert.ToInt32(ddlFleet_AddVessel.SelectedValue)
                                                  , Convert.ToInt32(ddlVesselManager.SelectedValue), UDFLib.ConvertDateToNull(dtTakeoverDate.Text),
                                                  UDFLib.ConvertDateToNull(dtHandoverDate.Text), UDFLib.ConvertIntegerToNull(ddlVesselFlage_AddVessel.SelectedValue), Convert.ToInt32(Session["UserID"].ToString()),
                                                  UDFLib.ConvertDecimalToNull(txtMinimumCTM.Text), chkSyncEnable.Checked == true ? "-1" : "0", FileName, UDFLib.ConvertIntegerToNull(ddlvessel_AddType.SelectedValue));
                FileUploader.PostedFile.SaveAs(Server.MapPath("~/Uploads/MEPowerCurve/" + FileName));

                objBLL.UPDATE_SURVEY_VesselDetails(txtVesselID.Text, txtCallSign.Text, txtIMONo.Text, txtLength.Text, txtMMSI.Text, UDFLib.ConvertDateToNull(txtYearBuilt.Text));
            }

            else
            {
                lblMessage.Text = datasize + " KB File size exceeds maximum limit";
            }
        }
        else
        {
            FileName = txtVesselShortName.Text + "_" + DateTime.Now.ToString("dd-MM-yyyy HH.mm.ss") + "_" + Path.GetFileName(strLocalPath);

            int Retval = objBLL.UPDATE_Vessel(Convert.ToInt32(txtVesselID.Text), null, txtVessel.Text, txtVesselShortName.Text, txtEmailID.Text, UDFLib.ConvertIntegerToNull(ddlFleet_AddVessel.SelectedValue)
                                              , UDFLib.ConvertIntegerToNull(ddlVesselManager.SelectedValue), UDFLib.ConvertDateToNull(dtTakeoverDate.Text),
                                              UDFLib.ConvertDateToNull(dtHandoverDate.Text), UDFLib.ConvertIntegerToNull(ddlVesselFlage_AddVessel.SelectedValue), Convert.ToInt32(Session["UserID"].ToString()),
                                              UDFLib.ConvertDecimalToNull(txtMinimumCTM.Text), chkSyncEnable.Checked == true ? "-1" : "0", null, UDFLib.ConvertIntegerToNull(ddlvessel_AddType.SelectedValue));
            //FileUploader.PostedFile.SaveAs(Server.MapPath("~/Uploads/MEPowerCurve/" + null));

            objBLL.UPDATE_SURVEY_VesselDetails(txtVesselID.Text, txtCallSign.Text, txtIMONo.Text, txtLength.Text, txtMMSI.Text, UDFLib.ConvertDateToNull(txtYearBuilt.Text));
        }
        BindVesselGrid();

        string js = "closeDiv('dvAddNewVessel');";

        ScriptManager.RegisterStartupScript(this, this.GetType(), "close", js, true);
    }