Example #1
0
        public List <DebitMemoModel> GetDebitListByLocationId(long?LocationId)
        {
            try
            {
                var status = 0;
                var result = new List <DebitMemoModel>();
                result = _workorderems.spGetDebitMemoList(LocationId, status).Select
                             (x => new DebitMemoModel()
                {
                    DebitId                  = x.DBM_Id,
                    Location                 = x.LCM_CMP_Id,// location id company
                    LocationName             = x.LocationName,
                    VendorId                 = x.CMP_Id,
                    VendorName               = x.CMP_NameLegal,
                    PurchaseOrderId          = x.DBM_PurchaseOrder,
                    ProductOrderName         = "PO" + x.DBM_PurchaseOrder,
                    DebitAmount              = x.DBM_DebitAmount,
                    Note                     = x.DBM_Note,
                    Status                   = x.DBM_Status,
                    EditStatus               = x.DBM_Status,
                    UploadedEditDocumentName = x.DBM_DocumentName,                                                             //to delete old document if new file added in edit
                    UploadedDocumentName     = x.DBM_DocumentName == null ? "" : HostingPrefix + DebitMemoDocumentPath.Replace("~", "") + x.DBM_DocumentName,
                    DisplayDate              = x.DBM_CreatedDate.HasValue ? x.DBM_CreatedDate.Value.ToString("MMM dd,yyyy"):"" //for nullable datetime check hasvalue and .value
                }).ToList();

                foreach (var item in result)
                {
                    if (item.Status != null)
                    {
                        DebitMemoStatus e = (DebitMemoStatus)item.Status;
                        item.DisplayDebitMemoStatus = e.ToString();
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #2
0
        private void LoadList()
        {
            DebitMemos clsDebitMemos = new DebitMemos();
            Common     Common        = new Common();

            string SortField = "DebitMemoID";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Desscending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            DateTime dteOrderStartDate = DateTime.MinValue;

            try { if (txtOrderStartDate.Text != string.Empty)
                  {
                      dteOrderStartDate = Convert.ToDateTime(txtOrderStartDate.Text + " " + txtOrderStartTime.Text);
                  }
            }
            catch { }

            DateTime dteOrderEndDate = DateTime.MinValue;

            try { if (txtOrderEndDate.Text != string.Empty)
                  {
                      dteOrderEndDate = Convert.ToDateTime(txtOrderEndDate.Text + " " + txtOrderEndTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingStartDate = DateTime.MinValue;

            try { if (txtPostingStartDate.Text != string.Empty)
                  {
                      dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingEndDate = DateTime.MinValue;

            try { if (txtPostingEndDate.Text != string.Empty)
                  {
                      dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text);
                  }
            }
            catch { }

            string          SearchKey = txtSearch.Text;
            DebitMemoStatus status    = (DebitMemoStatus)Enum.Parse(typeof(DebitMemoStatus), cboStatus.SelectedItem.Value);

            PageData.DataSource = clsDebitMemos.SearchAsDataTable(status, dteOrderStartDate, dteOrderEndDate, dtePostingStartDate, dtePostingEndDate, SearchKey, SortField, sortoption).DefaultView;

            clsDebitMemos.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Example #3
0
        protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                LoadSortFieldOptions(e);
            }
            else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView dr = (DataRowView)e.Item.DataItem;

                HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
                chkList.Value = dr["DebitMemoID"].ToString();

                HyperLink lnkMemoNo = (HyperLink)e.Item.FindControl("lnkMemoNo");
                lnkMemoNo.Text = dr["MemoNo"].ToString();
                Common Common  = new Common();
                string stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&memoid=" + Common.Encrypt(chkList.Value.ToString(), Session.SessionID);
                lnkMemoNo.NavigateUrl = "Default.aspx" + stParam;

                DebitMemoStatus status = (DebitMemoStatus)Enum.Parse(typeof(DebitMemoStatus), dr["DebitMemoStatus"].ToString());
                if (status == DebitMemoStatus.Posted || status == DebitMemoStatus.Cancelled || lnkMemoNo.Text.Substring(0, Constants.PURCHASE_RETURN_CODE.Length) == Constants.PURCHASE_RETURN_CODE)
                {
                    chkList.Attributes.Add("disabled", "false");
                    ImageButton imgItemDelete = (ImageButton)e.Item.FindControl("imgItemDelete");
                    ImageButton imgItemEdit   = (ImageButton)e.Item.FindControl("imgItemEdit");
                    ImageButton imgItemPost   = (ImageButton)e.Item.FindControl("imgItemPost");
                    imgItemDelete.Enabled = false; imgItemDelete.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    imgItemEdit.Enabled   = false; imgItemEdit.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    imgItemPost.Enabled   = false; imgItemPost.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                }
                Label lblMemoDate = (Label)e.Item.FindControl("lblMemoDate");
                lblMemoDate.Text = Convert.ToDateTime(dr["MemoDate"]).ToString("yyyy-MM-dd HH:mm:ss");

                Label lblSupplierID = (Label)e.Item.FindControl("lblSupplierID");
                lblSupplierID.Text = dr["SupplierID"].ToString();

                HyperLink lblSupplierCode = (HyperLink)e.Item.FindControl("lblSupplierCode");
                lblSupplierCode.Text = dr["SupplierCode"].ToString();
                stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(lblSupplierID.Text, Session.SessionID);
                lblSupplierCode.NavigateUrl = Constants.ROOT_DIRECTORY + "/PurchasesAndPayables/_Vendor/Default.aspx" + stParam;

                DateTime PostingDate    = Convert.ToDateTime(dr["PostingDate"]);
                Label    lblPostingDate = (Label)e.Item.FindControl("lblPostingDate");
                if (PostingDate == DateTime.MinValue)
                {
                    lblPostingDate.Text = "Not yet posted";
                }
                else
                {
                    lblPostingDate.Text = PostingDate.ToString("yyyy-MM-dd");
                }

                Label lblBranchID = (Label)e.Item.FindControl("lblBranchID");
                lblBranchID.Text = dr["BranchID"].ToString();
                Label lblBranchCode = (Label)e.Item.FindControl("lblBranchCode");
                lblBranchCode.Text = dr["BranchCode"].ToString();

                Label lblSubTotal = (Label)e.Item.FindControl("lblSubTotal");
                lblSubTotal.Text = Convert.ToDecimal(dr["SubTotal"]).ToString("#,##0.#0");

                Label lblRemarks = (Label)e.Item.FindControl("lblRemarks");
                lblRemarks.Text = dr["Remarks"].ToString();

                //For anchor
                //				HtmlGenericControl divExpCollAsst = (HtmlGenericControl) e.Item.FindControl("divExpCollAsst");

                //				HtmlAnchor anchorDown = (HtmlAnchor) e.Item.FindControl("anchorDown");
                //				anchorDown.HRef = "javascript:ToggleDiv('" +  divExpCollAsst.ClientID + "')";
            }
        }
Example #4
0
        public System.Data.DataTable SearchAsDataTable(DebitMemoStatus status, DateTime OrderStartDate, DateTime OrderEndDate, DateTime PostingStartDate, DateTime PostingEndDate, string SearchKey, string SortField, SortOption SortOrder, Int32 limit = 0, eSalesFilter clseSalesFilter = new eSalesFilter())
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                
                string SQL = SQLSelect() + "AND DebitMemoStatus = @Status " +
                                "AND (MemoNo LIKE @SearchKey or MemoDate LIKE @SearchKey or SupplierCode LIKE @SearchKey " +
                                        "or SupplierContact LIKE @SearchKey or BranchCode LIKE @SearchKey or RequiredPostingDate LIKE @SearchKey) ";
                
                if (OrderStartDate != DateTime.MinValue) SQL += "AND MemoDate >= @OrderStartDate ";
                if (OrderEndDate != DateTime.MinValue) SQL += "AND MemoDate <= @OrderEndDate ";
                if (PostingStartDate != DateTime.MinValue) SQL += "AND PostingDate >= @PostingStartDate ";
                if (PostingEndDate != DateTime.MinValue) SQL += "AND PostingDate <= @PostingEndDate ";

                if (clseSalesFilter.FilterIncludeIneSales)
                {
                    SQL += "AND a.IncludeIneSales = @IncludeIneSales ";
                    cmd.Parameters.AddWithValue("@IncludeIneSales", clseSalesFilter.IncludeIneSales);
                }

                SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "DebitMemoID") + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                cmd.Parameters.AddWithValue("@Status", status.ToString("d"));
                cmd.Parameters.AddWithValue("@SearchKey", "%" + SearchKey + "%");

                if (OrderStartDate != DateTime.MinValue) cmd.Parameters.AddWithValue("@OrderStartDate", OrderStartDate.ToString("yyyy-MM-dd HH:mm:ss"));
                if (OrderEndDate != DateTime.MinValue) cmd.Parameters.AddWithValue("@OrderEndDate", OrderEndDate.ToString("yyyy-MM-dd HH:mm:ss"));
                if (PostingStartDate != DateTime.MinValue) cmd.Parameters.AddWithValue("@PostingStartDate", PostingStartDate.ToString("yyyy-MM-dd HH:mm:ss"));
                if (PostingEndDate != DateTime.MinValue) cmd.Parameters.AddWithValue("@PostingEndDate", PostingEndDate.ToString("yyyy-MM-dd HH:mm:ss"));

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return dt;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }	
Example #5
0
        public System.Data.DataTable ListAsDataTable(DebitMemoStatus DebitMemoStatus = DebitMemoStatus.All, DebitMemoDetails searchKey = new DebitMemoDetails(), DateTime? MemoStartDate = null, DateTime? MemoEndDate = null, DateTime? PostingStartDate = null, DateTime? PostingEndDate = null, string SortField = "DebitMemoID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0, Int64 SupplierID = 0, Int64 DebitMemoID = 0, eSalesFilter clseSalesFilter = new eSalesFilter())
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                // Note WHERE is already included in  SQLSelect()
                string SQL = SQLSelect();

                if (DebitMemoStatus != DebitMemoStatus.All)
                {
                    SQL += "AND DebitMemoStatus = @DebitMemoStatus ";
                    cmd.Parameters.AddWithValue("@DebitMemoStatus", DebitMemoStatus.ToString("d"));
                }

                if (DebitMemoID != 0)
                {
                    SQL += "AND DebitMemoID = @DebitMemoID ";
                    cmd.Parameters.AddWithValue("@DebitMemoID", DebitMemoID);
                }

                if (SupplierID != 0)
                {
                    SQL += "AND SupplierID >= @SupplierID ";
                    cmd.Parameters.AddWithValue("@SupplierID", SupplierID);
                }

                if ((MemoStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : MemoStartDate) != Constants.C_DATE_MIN_VALUE)
                {
                    SQL += "AND MemoDate >= @MemoStartDate ";
                    cmd.Parameters.AddWithValue("@MemoStartDate", MemoStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if ((MemoEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : MemoEndDate) != Constants.C_DATE_MIN_VALUE)
                {
                    SQL += "AND MemoDate <= @MemoEndDate ";
                    cmd.Parameters.AddWithValue("@MemoEndDate", MemoEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if ((PostingStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingStartDate) != Constants.C_DATE_MIN_VALUE)
                {
                    SQL += "AND PostingDate >= @PostingStartDate ";
                    cmd.Parameters.AddWithValue("@PostingStartDate", PostingStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if ((PostingEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingEndDate) != Constants.C_DATE_MIN_VALUE)
                {
                    SQL += "AND PostingDate <= @PostingEndDate ";
                    cmd.Parameters.AddWithValue("@PostingEndDate", PostingEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if (clseSalesFilter.FilterIncludeIneSales)
                {
                    SQL += "AND a.IncludeIneSales = @IncludeIneSales ";
                    cmd.Parameters.AddWithValue("@IncludeIneSales", clseSalesFilter.IncludeIneSales);
                }

                SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "DebitMemoID") + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return dt;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }