protected void btnSave_Click(object sender, EventArgs e) { if (ddlJobType.SelectedIndex == 1 || ddlJobType.SelectedIndex == 2) { if (!string.IsNullOrEmpty(txtMTWeight.Text)) { if (Convert.ToDecimal(txtMTWeight.Text) == 0) { lblError.Text = "Weight in MT is compulsory"; return; } else { lblError.Text = ""; } } else { lblError.Text = "Weight in MT is compulsory"; return; } } else { if (!string.IsNullOrEmpty(txtGrossWeight.Text)) { if (Convert.ToDecimal(txtGrossWeight.Text) == 0) { lblError.Text = "Weight in KG is compulsory"; return; } } else { lblError.Text = "Weight in KG is compulsory"; return; } } IJob job = new JobEntity(); if (ViewState["JOBID"] != null) { job.JobID = Convert.ToInt32(ViewState["JOBID"]); job.JobActive = 'E'; job.JobNo = txtJobNo.Text; } else { job.JobActive = 'A'; } job.JobTypeID = ddlJobType.SelectedValue.ToInt(); job.JobScopeID = ddlJobScope.SelectedValue.ToInt(); job.JobDate = Convert.ToDateTime(txtJobDate.Text); job.OpsLocID = ddlOpsControlled.SelectedValue.ToInt(); job.jobLocID = ddlDocControlled.SelectedValue.ToInt(); //job. = ddlDocControlled.SelectedValue.ToInt(); job.SalesmanID = ddlSalesControlled.SelectedValue.ToInt(); job.SmodeID = ddlShipmentMode.SelectedValue.ToInt(); job.PrDocID = ddlPrimeDocs.SelectedValue.ToInt(); job.PrintHBL = chkPrintHBL.Checked; job.HBLFormatID = ddlHblFormat.SelectedValue.ToInt(); if (ddlJobType.SelectedIndex == 1 || ddlJobType.SelectedIndex == 2) { //job.ttl20 = Convert.ToInt32(txtTTL20.Text); //job.ttl40 = Convert.ToInt32(txtTTL40.Text); if (!string.IsNullOrEmpty(txtMTWeight.Text)) { job.weightMT = Convert.ToDecimal(txtMTWeight.Text); } else { job.weightMT = 0; } if (!string.IsNullOrEmpty(txtCBMVolume.Text)) { job.volCBM = Convert.ToDecimal(txtCBMVolume.Text); } else { job.volCBM = 0; } //job.RevTon = Convert.ToDecimal(txtRevenue.Text); } //else if (ddlJobType.SelectedIndex == 3 || ddlJobType.SelectedIndex == 5) //{ // if (!string.IsNullOrEmpty(txtMTWeight.Text)) // job.weightMT = Convert.ToDecimal(txtMTWeight.Text); // else // job.weightMT = 0; // if (!string.IsNullOrEmpty(txtCBMVolume.Text)) // job.volCBM = Convert.ToDecimal(txtCBMVolume.Text); // else // job.volCBM = 0; // if (!string.IsNullOrEmpty(txtRevenue.Text)) // job.RevTon = Convert.ToDecimal(txtRevenue.Text); // else // job.RevTon = 0; //} else if (ddlJobType.SelectedIndex == 3 || ddlJobType.SelectedIndex == 4) { if (!string.IsNullOrEmpty(txtGrossWeight.Text)) { job.grwt = Convert.ToDecimal(txtGrossWeight.Text); } else { job.grwt = 0; } if (!string.IsNullOrEmpty(txtVolumeWeight.Text)) { job.VolWt = Convert.ToDecimal(txtVolumeWeight.Text); } else { job.VolWt = 0; } //job.RevTon = Convert.ToDecimal(txtRevenue.Text); } job.PlaceOfReceipt = txtPlaceReciept.Text; //job.fk_LportID = ddlPortLoading.SelectedValue.ToInt(); //job.fk_DportID = ddlPortDischarge.SelectedValue.ToInt(); job.fk_DportID = Convert.ToInt32(ViewState["PORTOFDISCHARGEID"]); job.fk_LportID = Convert.ToInt32(ViewState["PORTOFLOADINGID"]); job.PlaceOfDelivery = txtDelivery.Text; job.FLineID = ddlShippingLine.SelectedValue.ToInt(); job.fk_CustID = ddlCustomer.SelectedValue.ToInt(); job.fk_CustAgentID = ddlCustomsAgent.SelectedValue.ToInt(); job.fk_TransID = ddlTransporter.SelectedValue.ToInt(); job.fk_OSID = ddlOverseasAgent.SelectedValue.ToInt(); job.CargoSource = Convert.ToChar(ddlCargoSource.SelectedValue); job.CompID = ddlCompany.SelectedValue.ToInt(); if (!string.IsNullOrEmpty(txtCreditDays.Text)) { job.CreditDays = Convert.ToInt32(txtCreditDays.Text); } else { job.CreditDays = 0; } //job.CreditDays = Convert.ToInt32(txtCreditDays.Text); job.Voyage = txtVoyageNo.Text; //job.Vessel = txtVesselName.Text; job.DocumentNo = txtDocumentNo.Text; job.JobNote1 = txtJobNote1.Text; job.JobNote2 = txtJobNote2.Text; job.CreatedBy = _userId; int CompanyId = 1; int outJobId = 0; int Status = JobBLL.AddEditJob(job, CompanyId, ref outJobId); if (Status == 1) { oJobBll = new JobBLL(); oJobBll.DeactivateAllContainersAgainstJobId(outJobId); AddContainers(outJobId); } ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Record saved successfully!'); window.location='" + string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], (HttpContext.Current.Request.ApplicationPath.Equals("/")) ? string.Empty : HttpContext.Current.Request.ApplicationPath) + "/Forwarding/Transaction/JobList.aspx';", true); }