Beispiel #1
0
        public static List <ISettlement> GetAllSettlements(SearchCriteria searchCriteria, int locationId)
        {
            string             strExecution = "[uspGetSettlement]";
            List <ISettlement> lstBL        = new List <ISettlement>();

            using (DbQuery oDq = new DbQuery(strExecution))
            {
                //oDq.AddIntegerParam("@pk_SettlementID", searchCriteria.IntegerOption1);
                oDq.AddIntegerParam("@Locationid", searchCriteria.LocationID);
                oDq.AddVarcharParam("@SchBLNo", 100, searchCriteria.BLNo);
                oDq.AddVarcharParam("@SchLine", 100, searchCriteria.LineName);
                oDq.AddVarcharParam("@SchLocation", 100, searchCriteria.LocName);
                oDq.AddVarcharParam("@SchSettlementNo", 100, searchCriteria.BookingNo);
                oDq.AddVarcharParam("@SortExpression", 100, searchCriteria.SortExpression);
                oDq.AddVarcharParam("@SortDirection", 100, searchCriteria.SortDirection);

                DataTableReader reader = oDq.GetTableReader();

                while (reader.Read())
                {
                    ISettlement bl = new SettlementEntity(reader);
                    lstBL.Add(bl);
                }

                reader.Close();
            }

            return(lstBL);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //string misc = string.Empty;



                if (txtPayToRcvdFrom.Text != hdnCustName.Value && CLUpload.HasFile == false)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Consignee Letter Upload is compulsory!');</script>", false);
                    return;
                }

                if (txtChequeDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Cheque Date is compulsory!');</script>", false);
                    return;
                }

                if (txtChequeDetail.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Cheque No is compulsory!');</script>", false);
                    return;
                }

                if (txtBankName.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('BankName is compulsory!');</script>", false);
                    return;
                }


                if (RRUpload.HasFile)
                {
                    var fileName = RRUpload.FileName;
                    var filext   = fileName.Substring(fileName.LastIndexOf(".") + 1);
                    if (filext.ToLower() != "pdf")
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Only pdf file is accepted!');</script>", false);
                        return;
                    }
                    var path        = Server.MapPath("~/Transaction/SettlementDocs");
                    var newFileName = "RR" + txtBlNo;  //  Guid.NewGuid().ToString();

                    if (!string.IsNullOrEmpty(path))
                    {
                        path           += @"\" + newFileName + System.IO.Path.GetExtension(fileName);
                        hdnRRPath.Value = path;
                        RRUpload.PostedFile.SaveAs(path);
                    }
                }

                if (CLUpload.HasFile)
                {
                    var fileName = CLUpload.FileName;
                    var filext   = fileName.Substring(fileName.LastIndexOf(".") + 1);
                    if (filext.ToLower() != "pdf")
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Only pdf file is accepted!');</script>", false);
                        return;
                    }
                    var path        = Server.MapPath("~/Transaction/SettlementDocs");
                    var newFileName = "CL" + txtBlNo;  //  Guid.NewGuid().ToString();

                    if (!string.IsNullOrEmpty(path))
                    {
                        path           += @"\" + newFileName + System.IO.Path.GetExtension(fileName);
                        hdnCLPath.Value = path;
                        CLUpload.PostedFile.SaveAs(path);
                    }
                }
                ISettlement Settlement = new SettlementEntity();
                BuildSettlementEntity(Settlement);
                long Settlementid = new SettlementBLL().SaveSettlement(Settlement);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Record saved successfully!');</script>", false);
                if (!ReferenceEquals(Request.QueryString["id"], null))
                {
                    Response.Redirect("~/Transaction/Settlement1.aspx");
                }
                else
                {
                    Response.Redirect("~/Transaction/Settlement1.aspx");
                }
                //ClearAll();

                //if (isedit == true)
                //    Response.Redirect("~/Export/Voyage.aspx");
                //else
                //    clearPage();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Record could not be saved due to ! " + ex.Message.ToString() + "');</script>", false);
            }
        }