//protected void btnAddGRN_Click(object sender, EventArgs e) //{ // try // { // ObjGRN.Rec_By = Master.LoggedUser.UserId; // ObjGRN.Rec_Date = dtpGRNDate.Date; // if (rblGRNType.SelectedValue == "1")//PO // { // ObjGRN.POId = Int32.Parse(ddlPOCode.SelectedValue.Trim() != "-1" ? ddlPOCode.SelectedValue.Trim() : "0"); // ObjGRN.InvId = null; // ObjGRN.CreditNote = String.Empty; // ObjGRN.SuplierInvNo = txtSupplierInvNo.Text.Trim(); // if (hdnOldInvNumber.Value.Trim() != txtSupplierInvNo.Text.Trim()) // { // if (true == new GRNDAO().IsSupplierInvNoExist(ObjGRN)) // { // lblError.Text = "Supplier Invoice Number Already exists!!"; // lblError.Visible = true; // return; // } // } // } // else if (rblGRNType.SelectedValue == "2")//Sales return // { // ObjGRN.POId = null; // ObjGRN.InvId = Int32.Parse(hdnInvoiceId.Value.Trim()); // ObjGRN.CreditNote = txtCreditNote.Text.Trim(); // ObjGRN.SuplierInvNo = String.Empty; // } // if (ObjGRN.Save()) // { // lblError.Visible = true; // lblError.Text = Constant.MSG_Save_SavedSeccessfully; // hdnPRId.Value = ObjGRN.GRNId.ToString(); // btnPrint.Visible = true; // btnSave.Enabled = false; // btnSave.CssClass = "show_success"; // } // else // { // btnPrint.Visible = false; // lblError.Visible = true; // lblError.Text = Constant.MSG_Save_NotSavedSeccessfully; // } // } // catch (Exception ex) // { // ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnAddGRN_Click(object sender, EventArgs e)"); // if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty) // Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false); // else // Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false); // } //} protected void btnConfirm_Click(object sender, EventArgs e) { try { Session["ObjGRN"] = null; Int64 GRNId = 0; if (Int64.TryParse(txtGrnId.Text.Trim(), out GRNId)) { ObjGRN.GRNId = GRNId; ObjGRN.GetGRNByID(); if (ObjGRN.POId.HasValue) { lblGRNError.Visible = false; lblGRNError.Text = String.Empty; PO purchaseorder = new PO(); purchaseorder.POId = ObjGRN.POId.Value; purchaseorder.GetPOByID(); lblSupInvNo.Text = ObjGRN.SuplierInvNo; lblPOCode.Text = purchaseorder.POCode; lblSupplierName.Text = purchaseorder.SupplierName; ddlItemCode.DataSource = new PurchaseReturnsDAO().GetItemsToReturnByGRNId(GRNId); ddlItemCode.DataTextField = "ItemCode"; ddlItemCode.DataValueField = "GRNDetailsId"; ddlItemCode.DataBind(); ddlItemCode.Items.Add(new ListItem("--Please Select--", "-1")); ddlItemCode.SelectedValue = "-1"; } else { lblGRNError.Visible = true; lblGRNError.Text = "Incorrect PO GRN Id"; } } else { return; } } catch (Exception ex) { ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnConfirm_Click(object sender, EventArgs e)"); if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty) Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false); else Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false); } }
/// <summary> /// Load the data for GRN Edit / View /// </summary> private void SetData() { try { if (ObjGRN.POId.HasValue) { hdnGRNType.Value = "1";//PO used in client side lblGRNType.Text = "Purchase Order"; int poId = ObjGRN.POId.Value; PO po = new PO(); po.POId = poId; po.GetPOByID(); lblSupplierName.Text = po.SupplierName; } else if (ObjGRN.InvId.HasValue)//Sales return used in client side { hdnGRNType.Value = "2"; lblGRNType.Text = "Sales Return"; lblTitle.Text = "GRN - Credit Note"; } lblGRNNo.Text = ObjGRN.GRNId.ToString(); hdnPOId.Value = ObjGRN.POId.ToString().Trim(); lblPOCode.Text = ObjGRNPO.POCode; lblPOAmount.Text = Decimal.Round(ObjGRNPO.POAmount, 2).ToString(); lblDate.Text = ObjGRN.Rec_Date.ToString("dd-MMM-yyyy"); if (ObjGRN.GRNInvoice.InvoiceNo != null) { lblInvoiceNo.Text = ObjGRN.GRNInvoice.InvoiceNo.Trim(); Customer cust = new Customer(); cust.CustomerID = ObjGRN.GRNInvoice.CustomerID.Value; cust.GetCustomerByID(); lblCustomerName.Text = cust.Cus_Name; lblCustomerCode.Text = cust.CustomerCode; } else { lblInvoiceNo.Text = String.Empty; } lblInvoiceTotal.Text = Decimal.Round(ObjGRN.GRNInvoice.GrandTotal, 2).ToString(); txtCreditNote.InnerHtml = ObjGRN.CreditNote.Trim(); lblSupplierInvNo.Text = ObjGRN.SuplierInvNo.Trim(); lblReceivedTotal.Text = Decimal.Round(ObjGRN.TotalAmount, 2).ToString(); gvItemList.DataSource = ObjGRN.GRNItems; gvItemList.DataBind(); } catch (Exception ex) { throw ex; } }