private void SaveData(string VesselId) { BLL.DBInteraction dbinteract = new BLL.DBInteraction(); bool isedit = VesselId != "-1" ? true : false; if (!isedit) { // if (dbinteract.GetPort(-1, txtPortCode.Text.Trim(), "").Tables[0].Rows.Count > 0) if (!dbinteract.IsUnique("trnVessel", "VesselName", txtVesselName.Text.Trim())) { GeneralFunctions.RegisterAlertScript(this, "Vessel Name must be unique. Please try with another one."); return; } } Entity.Vessel vessel = new Entity.Vessel(); vessel.VesselID = Convert.ToInt32(VesselId); vessel.AgentCode = txtAgentCode.Text.ToUpper(); //vessel.CallSign = txtCallSign.Text; vessel.IMONumber = txtIMO.Text.ToUpper(); //string port = ((TextBox)AutoCompletepPort1.FindControl("txtPort")).Text; //port = port.Contains(',') && port.Split(',').Length >= 1 ? port.Split(',')[1].Trim() : ""; //vessel.LastPortCalled = dbinteract.GetId("Port", port); vessel.MasterName = txtMasterCode.Text.ToUpper(); vessel.PANNo = txtPan.Text.ToUpper(); vessel.ShippingLineCode = txtShipLineCode.Text.ToUpper(); vessel.VesselFlag = dbinteract.GetId("Country", ((TextBox)AutoCompleteCountry1.FindControl("txtCountry")).Text); vessel.VesselName = txtVesselName.Text.ToUpper(); vessel.VesselPrefix = Convert.ToInt32(ddlVesselPrefix.SelectedValue); vessel.CallSign = TxtCallSign.Text.ToUpper(); vessel.VesselAbbr = txtVesselAbbr.Text.ToUpper(); //if (vessel.LastPortCalled == 0) //{ // GeneralFunctions.RegisterAlertScript(this, "Last_Port_Called is Invalid. Please rectify."); // return; //} if (vessel.VesselFlag == 0) { GeneralFunctions.RegisterAlertScript(this, "Vessel_Flag is Invalid. Please rectify."); return; } else if (ddlVesselPrefix.SelectedValue == "0") { GeneralFunctions.RegisterAlertScript(this, "Please Select a vessel prefix first"); return; } int result = dbinteract.AddEditVessel(_userId, isedit, vessel); if (result > 0) { Response.Redirect("~/MasterModule/ManageVessel.aspx"); } else { GeneralFunctions.RegisterAlertScript(this, "Error Occured"); } }