Ejemplo n.º 1
0
        protected void dgJob_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            // TODO eItem
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                eSelfBillStatus state = (eSelfBillStatus)Enum.Parse(typeof(eSelfBillStatus), (string)(((DataRowView)e.Item.DataItem)["Description"]));

                if (state == eSelfBillStatus.Accepted || state == eSelfBillStatus.Invoiced)
                {
                    e.Item.Cells[8].Visible = false;
                }
            }
            else if (e.Item.ItemType == ListItemType.EditItem || e.Item.ItemType == ListItemType.SelectedItem)
            {
                DropDownList state = (DropDownList)e.Item.FindControl("cboJobSelfBillState");
                if ((eSelfBillStatus)Enum.Parse(typeof(eSelfBillStatus), state.SelectedValue) == eSelfBillStatus.Invoiced)
                {
                    e.Item.Cells[8].Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void dgJob_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            DataGridItem updatingItem = dgJob.Items[e.Item.ItemIndex];

            Facade.IJob facJob = new Facade.Job();

            int          invoiceId           = Convert.ToInt32(((Label)updatingItem.FindControl("lblInvoiceId")).Text);
            int          jobId               = Convert.ToInt32(((Label)updatingItem.FindControl("lblJobId")).Text);
            string       whom                = ((TextBox)updatingItem.FindControl("txtWhom")).Text;
            decimal      amount              = Convert.ToDecimal(((TextBox)updatingItem.FindControl("txtChargeAmount")).Text);
            DropDownList cboJobSelfBillState = (DropDownList)updatingItem.FindControl("cboJobSelfBillState");

            eSelfBillStatus status = (eSelfBillStatus)Enum.Parse(typeof(eSelfBillStatus), cboJobSelfBillState.SelectedValue, true);

            // TODO: May need to check that the State is not awaiting but has someone in the Whom section

            string userId  = ((Entities.CustomPrincipal)Page.User).UserName;
            bool   success = facJob.Update(invoiceId, jobId, whom, status, amount, userId);

            if (success)
            {
                lblConfirmation.Text    = "The Self Bill Job was updated successfully.";
                lblConfirmation.Visible = true;
                dgJob.EditItemIndex     = -1;

                // TODO: Update the job in viewstate
                // ViewState[C_JOB_VS] = m_job;

                // Rebind the datagrid
                PopulateJob();
            }
            else
            {
                lblConfirmation.Text    = "The Self Bill Job was not updated successfully.";
                lblConfirmation.Visible = true;
            }
        }