Example #1
0
 protected void gvPurchaseOrder_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         _currentPurchaseOrder = new PurchaseOrderDL();
         _currentPurchaseOrder.PurchaseOrderID = Convert.ToInt32(gvPurchaseOrder.DataKeys[e.RowIndex].Value);
         _currentPurchaseOrder.ScreenMode      = ScreenMode.Delete;
         TransactionResult transactionResult = _currentPurchaseOrder.Commit();
         StringBuilder     stringBuilder     = new StringBuilder();
         stringBuilder.Append(string.Concat("<script>alert(\'", transactionResult.Message.ToString(), ".\');"));
         stringBuilder.Append("</script>");
         ScriptManager.RegisterStartupScript(base.Page, typeof(string), "MyScript", stringBuilder.ToString(), false);
         if (transactionResult.Status == TransactionStatus.Success)
         {
             GetPurchaseOrderDetails();
         }
     }
     catch (Exception exception1)
     {
         ErrorLog.LogErrorMessageToDB("ManagePurchaseOrder.aspx", "", "gvPurchaseOrder_RowDeleting", exception1.Message.ToString(), new ACEConnection());
         throw;
     }
 }
        protected void btnPurchaseOrderAdd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string   dtFormat = _dateFormat;
                DateTime dTime;

                PurchaseOrderDL _currentPurchaseOrder = new PurchaseOrderDL();
                bool            bl = hfPurchaseOrderID.Value.ToString() == "0";
                _currentPurchaseOrder.AddEditOption   = !bl ? 1 : 0;
                _currentPurchaseOrder.PurchaseOrderID = Convert.ToInt32(hfPurchaseOrderID.Value.ToString());
                dTime = DateTime.ParseExact(txtPODate.Text, dtFormat, null);
                _currentPurchaseOrder.PurchaseOrderNo = txtPONO.Text;

                _currentPurchaseOrder.BuyerID           = Convert.ToInt32(ddlContact.SelectedValue);
                _currentPurchaseOrder.SendToID          = Convert.ToInt32(hfCompanyID.Value);
                _currentPurchaseOrder.PurchaseOrderDate = dTime;
                _currentPurchaseOrder.Currency          = Convert.ToString(ddlCurrency.SelectedValue);
                _currentPurchaseOrder.Shipment          = Convert.ToString(ddlShipment.SelectedValue);
                _currentPurchaseOrder.TelNo             = Convert.ToString(txtTel.Text);
                _currentPurchaseOrder.GrandTotal        = Convert.ToDecimal(lblTotalCost.Text);
                dTime = GetTodayDate(dtFormat, dTime);

                _currentPurchaseOrder.AuditDate = dTime;
                _currentPurchaseOrder.AuditID   = Convert.ToInt32(hfUserID.Value);


                _currentPurchaseOrder.ScreenMode = ScreenMode.Add;
                TransactionResult transactionResult = _currentPurchaseOrder.Commit();

                bl = transactionResult.Status != TransactionStatus.Success;
                if (!bl)
                {
                    hfPurchaseOrderID.Value = _currentPurchaseOrder.PurchaseOrderID.ToString();

                    trEnablePurchaseWorkOrder.Visible = true;

                    //OrderAcceptanceParticularsListDL listDL;

                    //foreach (GridViewRow innerRow in gvPurchaseWorkOrder.Rows)
                    //{

                    //    listDL = new OrderAcceptanceParticularsListDL();

                    //    if (innerRow.Cells[3].Text.ToString() == "")
                    //        innerRow.Cells[3].Text = "0";

                    //    bool b2 = innerRow.Cells[3].Text.ToString() == "0";
                    //    listDL.AddEditOption = !b2 ? 1 : 0;

                    //    listDL.OrderAcceptanceParticularsListID = Convert.ToInt32(innerRow.Cells[3].Text.ToString());
                    //    listDL.PurchaseOrderID = Convert.ToInt32(hfPurchaseOrderID.Value.ToString());
                    //    listDL.ParticularsID = Convert.ToInt32(innerRow.Cells[1].Text.ToString());

                    //    RadioButton rbYes = (RadioButton)innerRow.Cells[4].FindControl("rbCheckYes");
                    //    RadioButton rbNo = (RadioButton)innerRow.Cells[4].FindControl("rbCheckNo");
                    //    TextBox txtRemarks = (TextBox)innerRow.Cells[5].FindControl("txtRemarks");
                    //    listDL.StatusYes = rbYes.Checked;
                    //    listDL.StatusNo = rbNo.Checked;
                    //    listDL.Remarks = txtRemarks.Text;

                    //    listDL.ScreenMode = ScreenMode.Add;
                    //    listDL.Commit();
                    //}



                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(string.Concat("<script>alert(\'", transactionResult.Message.ToString(), ".\');"));
                    stringBuilder.Append("</script>");
                    ScriptManager.RegisterStartupScript(base.Page, typeof(string), "MyScript", stringBuilder.ToString(), false);
                }
                else
                {
                    //txtAvailablecount.Text = "0";
                    //lblPurchaseOrderID.Text = "0";
                }
            }
            catch (Exception exception1)
            {
                ErrorLog.LogErrorMessageToDB("ManagePurchaseOrder.aspx", "", "btnPurchaseOrderAdd_Click", exception1.Message.ToString(), new ACEConnection());
                throw;
            }
        }