Beispiel #1
0
        public static void GetRadDateInput(Control oMe, Oracle.DataAccess.Client.OracleConnection conn)
        {
            int          cnt   = oMe.Controls.Count;
            RadDateInput cntrl = null;

            for (int i = 0; i < cnt; i++)
            {
                string s = oMe.Controls[i].GetType().ToString();
                if ((oMe.Controls[i].GetType().ToString() ==
                     "Telerik.Web.UI.RadDateInput"))
                {
                    cntrl = (RadDateInput)oMe.Controls[i];
                    SaveControl(cntrl.ID, "RadDateInput", conn);
                }
                else
                if (oMe.Controls[i].HasControls())
                {
                    GetRadDateInput(oMe.Controls[i], conn);
                }
            }
        }
        public static void ProcessEnableVisible(Page wpage, string control_name, string control_type, string control_state_status, int iAction)
        {
            if (control_type.Equals("TextBox"))
            {
                TextBox txt = Bas_Utility.Utilities.GetTextBox(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        switch (iAction)
                        {
                        case 1:
                            txt.Enabled = true;
                            break;

                        case 2:
                            txt.Visible = true;
                            break;
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled   = false;
                                txt.BackColor = System.Drawing.Color.FromName("ffffcc");
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }

            // --------------------------- Panel
            if (control_type.Equals("Panel"))
            {
                Panel pnl = Bas_Utility.Utilities.GetPanel(wpage, control_name);
                if (pnl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        switch (iAction)
                        {
                        case 1:
                            pnl.Enabled = true;
                            break;

                        case 2:
                            pnl.Visible = true;
                            break;
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                pnl.Enabled   = false;
                                pnl.BackColor = System.Drawing.Color.FromName("ffffcc");
                                break;

                            case 2:
                                pnl.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }

            // --------------------------- DropDownList
            if (control_type.Equals("DropDownList"))
            {
                DropDownList ddl = Bas_Utility.Utilities.GetDropDown(wpage, control_name);
                if (ddl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ddl.Enabled = true;
                                break;

                            case 2:
                                ddl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ddl.Enabled   = false;
                            ddl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ddl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- ListBox
            if (control_type.Equals("ListBox"))
            {
                ListBox ddl = Bas_Utility.Utilities.GetListBox(wpage, control_name);
                if (ddl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ddl.Enabled = true;
                                break;

                            case 2:
                                ddl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ddl.Enabled   = false;
                            ddl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ddl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- RadioButton
            if (control_type.Equals("RadioButton"))
            {
                RadioButton ddl = Bas_Utility.Utilities.GetRadioButton(wpage, control_name);
                if (ddl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ddl.Enabled = true;
                                break;

                            case 2:
                                ddl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ddl.Enabled   = false;
                            ddl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ddl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- CheckBoxList
            if (control_type.Equals("CheckBoxList"))
            {
                CheckBoxList ddl = Bas_Utility.Utilities.GetCheckBoxList(wpage, control_name);
                if (ddl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ddl.Enabled = true;
                                break;

                            case 2:
                                ddl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ddl.Enabled   = false;
                            ddl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ddl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- CheckBox
            if (control_type.Equals("CheckBox"))
            {
                CheckBox ddl = Bas_Utility.Utilities.GetCheckBox(wpage, control_name);
                if (ddl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ddl.Enabled = true;
                                break;

                            case 2:
                                ddl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ddl.Enabled   = false;
                            ddl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ddl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- LinkButton
            if (control_type.Equals("LinkButton"))
            {
                LinkButton cntrl = Bas_Utility.Utilities.GetLinkButton(wpage, control_name);
                if (cntrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                cntrl.Enabled = true;
                                break;

                            case 2:
                                cntrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            cntrl.Enabled   = false;
                            cntrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            cntrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- LinkButton
            if (control_type.Equals("LinkButton"))
            {
                LinkButton cntrl = Bas_Utility.Utilities.GetLinkButton(wpage, control_name);
                if (cntrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                cntrl.Enabled = true;
                                break;

                            case 2:
                                cntrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            cntrl.Enabled   = false;
                            cntrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            cntrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- ImageButton
            if (control_type.Equals("ImageButton"))
            {
                ImageButton cntrl = Bas_Utility.Utilities.GetImageButton(wpage, control_name);
                if (cntrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                cntrl.Enabled = true;
                                break;

                            case 2:
                                cntrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            cntrl.Enabled   = false;
                            cntrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            cntrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }

            // --------------------------- HyperLink
            if (control_type.Equals("HyperLink"))
            {
                HyperLink cntrl = Bas_Utility.Utilities.GetHyperLink(wpage, control_name);
                if (cntrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                cntrl.Enabled = true;
                                break;

                            case 2:
                                cntrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            cntrl.Enabled   = false;
                            cntrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            cntrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- HyperLink
            if (control_type.Equals("HyperLink"))
            {
                HyperLink cntrl = Bas_Utility.Utilities.GetHyperLink(wpage, control_name);
                if (cntrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                cntrl.Enabled = true;
                                break;

                            case 2:
                                cntrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            cntrl.Enabled   = false;
                            cntrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            cntrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- RadioButton
            if (control_type.Equals("RadioButton"))
            {
                RadioButton ctrl = Bas_Utility.Utilities.GetRadioButton(wpage, control_name);
                if (ctrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ctrl.Enabled = true;
                                break;

                            case 2:
                                ctrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ctrl.Enabled   = false;
                            ctrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ctrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- RadioButton
            if (control_type.Equals("RadioButton"))
            {
                RadioButton ctrl = Bas_Utility.Utilities.GetRadioButton(wpage, control_name);
                if (ctrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ctrl.Enabled = true;
                                break;

                            case 2:
                                ctrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ctrl.Enabled   = false;
                            ctrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ctrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- CheckBoxList
            if (control_type.Equals("CheckBoxList"))
            {
                CheckBoxList ctrl = Bas_Utility.Utilities.GetCheckBoxList(wpage, control_name);
                if (ctrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ctrl.Enabled = true;
                                break;

                            case 2:
                                ctrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ctrl.Enabled   = false;
                            ctrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ctrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- CheckBox
            if (control_type.Equals("CheckBox"))
            {
                CheckBox ctrl = Bas_Utility.Utilities.GetCheckBox(wpage, control_name);
                if (ctrl != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                ctrl.Enabled = true;
                                break;

                            case 2:
                                ctrl.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (iAction)
                        {
                        case 1:
                            ctrl.Enabled   = false;
                            ctrl.BackColor = System.Drawing.Color.FromName("ffffcc");
                            break;

                        case 2:
                            ctrl.Visible = false;
                            break;
                        }
                    }
                }
                return;
            }
            // --------------------------- RadMaskedTextBox
            if (control_type.Equals("RadMaskedTextBox"))
            {
                RadMaskedTextBox txt = Bas_Utility.Utilities.GetRadMaskedTextBox(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }

            // --------------------------- RadTextBox
            if (control_type.Equals("RadTextBox"))
            {
                RadTextBox txt = Bas_Utility.Utilities.GetRadTextBox(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
            // --------------------------- RadComboBox
            if (control_type.Equals("RadComboBox"))
            {
                RadComboBox txt = Bas_Utility.Utilities.GetRadComboBox(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
            // --------------------------- RadDateInput
            if (control_type.Equals("RadDateInput"))
            {
                RadDateInput txt = Bas_Utility.Utilities.GetRadDateInput(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
            // --------------------------- RadDatePicker
            if (control_type.Equals("RadDatePicker"))
            {
                RadDatePicker txt = Bas_Utility.Utilities.GetRadDatePicker(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
            // --------------------------- RadEditor
            if (control_type.Equals("RadEditor"))
            {
                RadEditor txt = Bas_Utility.Utilities.GetRadEditor(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
            // --------------------------- RadMaskedTextBox
            if (control_type.Equals("RadMaskedTextBox"))
            {
                RadMaskedTextBox txt = Bas_Utility.Utilities.GetRadMaskedTextBox(wpage, control_name);
                if (txt != null)
                {
                    if (control_state_status.Equals("1"))
                    {
                        if (control_state_status.Equals("1"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = true;
                                break;

                            case 2:
                                txt.Visible = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (control_state_status.Equals("0"))
                        {
                            switch (iAction)
                            {
                            case 1:
                                txt.Enabled = false;
                                break;

                            case 2:
                                txt.Visible = false;
                                break;
                            }
                        }
                    }
                }
                return;
            }
        }
Beispiel #3
0
        void gvPreInvoices_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            string tableName = e.Item.OwnerTableView.Name;

            if (tableName == PreInvoiceTableName)
            {
                #region Pre Invoice Table
                if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.EditItem)
                {
                    DataRowView drv = (DataRowView)e.Item.DataItem;

                    RadDateInput rdiInvoiceDate = e.Item.FindControl("rdiInvoiceDate") as RadDateInput;

                    CheckBox chkPreInvoice = e.Item.FindControl("chkPreInvoice") as CheckBox;
                    if (chkPreInvoice != null)
                    {
                        chkPreInvoice.Attributes.Add("PreInvoiceId", drv["PreInvoiceId"].ToString());
                    }

                    RadTextBox rtClientReference        = e.Item.FindControl("rtClientReference") as RadTextBox;
                    RadTextBox rtPurchaseOrderReference = e.Item.FindControl("rtPurchaseOrderReference") as RadTextBox;

                    HtmlInputRadioButton rdoDoNothing      = e.Item.FindControl("rdoDoNothing") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoReject         = e.Item.FindControl("rdoReject") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApprove        = e.Item.FindControl("rdoApprove") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApproveAndPost = e.Item.FindControl("rdoApproveAndPost") as HtmlInputRadioButton;
                    HtmlInputCheckBox    chkUseHeadedPaper = e.Item.FindControl("chkUseHeadedPaper") as HtmlInputCheckBox;

                    HiddenField hidIsDirty = e.Item.FindControl("hidIsDirty") as HiddenField;

                    DropDownList cboTaxRate = e.Item.FindControl("cboTaxRate") as DropDownList;

                    Label lblPendingChanges      = e.Item.FindControl("lblPendingChanges") as Label;
                    Label lblNetAmount           = e.Item.FindControl("lblNetAmount") as Label;
                    Label lblExtraAmount         = e.Item.FindControl("lblExtraAmount") as Label;
                    Label lblFuelSurchargeAmount = e.Item.FindControl("lblFuelSurchargeAmount") as Label;
                    Label lblTaxAmount           = e.Item.FindControl("lblTaxAmount") as Label;
                    Label lblTotalAmount         = e.Item.FindControl("lblTotalAmount") as Label;

                    rdoDoNothing.Name      += "_" + e.Item.ItemIndex.ToString();
                    rdoReject.Name         += "_" + e.Item.ItemIndex.ToString();
                    rdoApprove.Name        += "_" + e.Item.ItemIndex.ToString();
                    rdoApproveAndPost.Name += "_" + e.Item.ItemIndex.ToString();

                    rdiInvoiceDate.SelectedDate = (DateTime)drv["InvoiceDate"];

                    hidIsDirty.Value = ((bool)drv["RequiresRegeneration"]).ToString();

                    if (this.dsTaxRates == null)
                    {
                        Orchestrator.Facade.Invoice facInvoice = new Orchestrator.Facade.Invoice();
                        DataSet taxRates = facInvoice.GetTaxRates((DateTime)drv["InvoiceDate"]);
                        this.dsTaxRates = taxRates;
                    }

                    cboTaxRate.DataTextField  = "Description";
                    cboTaxRate.DataValueField = "VatNo";
                    cboTaxRate.DataSource     = this.dsTaxRates;
                    cboTaxRate.DataBind();
                    cboTaxRate.ClearSelection();

                    int taxRateID = 0;
                    int.TryParse(drv["TaxRateID"].ToString(), out taxRateID);
                    if (cboTaxRate.Items.FindByValue(taxRateID.ToString()) == null)
                    {
                        ListItem newItem = new ListItem("New Standard", taxRateID.ToString());
                        cboTaxRate.Items.Add(newItem);
                    }

                    cboTaxRate.Items.FindByValue(taxRateID.ToString()).Selected = true;

                    if (drv["ClientInvoiceReference"] != DBNull.Value)
                    {
                        rtClientReference.Text = (string)drv["ClientInvoiceReference"];
                    }
                    else
                    {
                        rtClientReference.Text = string.Empty;
                    }

                    if (drv["PurchaseOrderReference"] != DBNull.Value)
                    {
                        rtPurchaseOrderReference.Text = (string)drv["PurchaseOrderReference"];
                    }
                    else
                    {
                        rtPurchaseOrderReference.Text = string.Empty;
                    }

                    int invoiceGenerationParametersID = int.Parse(drv["InvoiceGenerationParametersID"].ToString());
                    if ((bool)drv["RequiresRegeneration"])
                    {
                        lblPendingChanges.Text = "Pending Changes...";
                        lblPendingChanges.Style.Remove("display");

                        rdoDoNothing.Style.Add("display", "none");
                        rdoReject.Style.Add("display", "none");
                        rdoApprove.Style.Add("display", "none");
                        rdoApproveAndPost.Style.Add("display", "none");
                    }
                    else if (this.PreInvoiceIdsSentToWorkFlow.Exists(p => p == invoiceGenerationParametersID))
                    {
                        lblPendingChanges.Text = "Processing...";
                        lblPendingChanges.Style.Remove("display");

                        rdoDoNothing.Style.Add("display", "none");
                        rdoReject.Style.Add("display", "none");
                        rdoApprove.Style.Add("display", "none");
                        rdoApproveAndPost.Style.Add("display", "none");
                        this.PreInvoiceIdsSentToWorkFlow.Remove(invoiceGenerationParametersID);
                    }
                    else
                    {
                        lblPendingChanges.Text = string.Empty;
                        lblPendingChanges.Style.Add("display", "none");

                        rdoDoNothing.Style.Remove("display");
                        rdoReject.Style.Remove("display");
                        rdoApprove.Style.Remove("display");
                        rdoApproveAndPost.Style.Remove("display");
                    }

                    int         lcID    = (int)drv["LCID"];
                    CultureInfo culture = new CultureInfo(lcID);

                    lblNetAmount.Text           = ((decimal)drv["ForeignNetAmount"]).ToString("C", culture);
                    lblExtraAmount.Text         = ((decimal)drv["ForeignExtraAmount"]).ToString("C", culture);
                    lblFuelSurchargeAmount.Text = ((decimal)drv["ForeignFuelSurchargeAmount"]).ToString("C", culture);
                    lblTaxAmount.Text           = ((decimal)drv["ForeignTaxAmount"]).ToString("C", culture);
                    lblTotalAmount.Text         = ((decimal)drv["ForeignTotalAmount"]).ToString("C", culture);

                    chkUseHeadedPaper.Checked = Orchestrator.Globals.Configuration.UseHeadedPaper;
                }
                else if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Header)
                {
                    RadioButton rdoDoNothing = e.Item.FindControl("rdoDoNothing") as RadioButton;
                    //RadioButton rdoReject = e.Item.FindControl("rdoReject") as RadioButton;
                    RadioButton rdoApprove        = e.Item.FindControl("rdoApprove") as RadioButton;
                    RadioButton rdoApproveAndPost = e.Item.FindControl("rdoApproveAndPost") as RadioButton;

                    rdoDoNothing.GroupName += "_Header";
                    //rdoReject.GroupName += "_Header";
                    rdoApprove.GroupName        += "_Header";
                    rdoApproveAndPost.GroupName += "_Header";

                    AddReaction(rdoDoNothing, "spnDoNothing");
                    //AddReaction(rdoReject, "spnReject");
                    AddReaction(rdoApprove, "spnApprove");
                    AddReaction(rdoApproveAndPost, "spnApproveAndPost");
                }
                #endregion
            }
            else if (tableName == PreInvoiceItemTableName)
            {
                #region Detail Table
                if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.EditItem)
                {
                    HiddenField hidOldRate          = e.Item.FindControl("hidOldRate") as HiddenField;
                    TextBox     txtRate             = e.Item.FindControl("txtRate") as TextBox;
                    Label       lblPalletSpaces     = e.Item.FindControl("lblPalletSpaces") as Label;
                    HtmlAnchor  lnkOrderId          = e.Item.FindControl("lnkOrderId") as HtmlAnchor;
                    Label       lblJobSubcontractId = e.Item.FindControl("lblJobSubcontractId") as Label;

                    DataRowView drv = e.Item.DataItem as DataRowView;

                    int itemID = (int)drv["ItemID"];
                    txtRate.Attributes.Add("ItemID", itemID.ToString());

                    if (Convert.ToBoolean(drv["IsOrder"]) == true)
                    {
                        lblJobSubcontractId.Visible = false;
                        lnkOrderId.Visible          = true;
                        lnkOrderId.InnerHtml        = itemID.ToString();
                        lnkOrderId.HRef             = "javascript:viewOrder(" + itemID.ToString() + ");";
                    }
                    else
                    {
                        lblJobSubcontractId.Visible = true;
                        lnkOrderId.Visible          = false;
                        lblJobSubcontractId.Text    = itemID.ToString();
                    }

                    int         lcID              = (int)drv["LCID"];
                    CultureInfo culture           = new CultureInfo(lcID);
                    int         rateDecimalPlaces = (int)drv["RateDecimalPlaces"];
                    if (rateDecimalPlaces != 2)
                    {
                        culture.NumberFormat.CurrencyDecimalDigits = rateDecimalPlaces;
                    }

                    txtRate.Text = ((decimal)drv["ForeignRate"]).ToString("C", culture);

                    lblPalletSpaces.Text = ((decimal)drv["PalletSpaces"]).ToString("F2");
                    hidOldRate.Value     = txtRate.Text;
                }
                #endregion
            }
        }
Beispiel #4
0
        private void SaveBatchChanges()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                string tableName    = row.OwnerTableView.Name;
                int    preInvoiceId = -1;
                int.TryParse(row.GetDataKeyValue("PreInvoiceID").ToString(), out preInvoiceId);

                if (tableName == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidIsDirty = row.FindControl("hidIsDirty") as HiddenField;
                    bool        isDirty    = false;

                    if (bool.TryParse(hidIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Update PreInvoice
                        DateTime?invoiceDate = null;
                        string   clientReference = string.Empty, purchaseOrderReference = string.Empty;
                        int      taxRateID = -1;

                        RadDateInput rdiInvoiceDate = row.FindControl("rdiInvoiceDate") as RadDateInput;

                        RadTextBox rtClientReference        = row.FindControl("rtClientReference") as RadTextBox;
                        RadTextBox rtPurchaseOrderReference = row.FindControl("rtPurchaseOrderReference") as RadTextBox;

                        DropDownList cboTaxRate = row.FindControl("cboTaxRate") as DropDownList;

                        if (rdiInvoiceDate.SelectedDate.HasValue)
                        {
                            invoiceDate = rdiInvoiceDate.SelectedDate.Value;
                        }

                        clientReference        = rtClientReference.Text;
                        purchaseOrderReference = rtPurchaseOrderReference.Text;

                        int.TryParse(cboTaxRate.SelectedValue, out taxRateID);

                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdatePreinvoiceDetails(preInvoiceId, invoiceDate, clientReference, purchaseOrderReference, taxRateID, userName);
                        #endregion
                    }
                }
                else if (tableName == PreInvoiceItemTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidInvoiceItemIsDirty = row.FindControl("hidInvoiceItemIsDirty") as HiddenField;
                    bool        isDirty = false;

                    HiddenField hidInvoiceItemPendingDelete = row.FindControl("hidInvoiceItemPendingDelete") as HiddenField;
                    bool        isPendingDelete             = false;

                    if (bool.TryParse(hidInvoiceItemPendingDelete.Value, out isPendingDelete) && isPendingDelete)
                    {
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();

                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                        // Update the rate (depends on item type - depends on invoice type)
                        int preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());

                        facPreInvoice.RemovePreInvoiceOrder(preInvoiceID, itemID);
                    }

                    else if (bool.TryParse(hidInvoiceItemIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Pre Invoice Item

                        decimal      rate       = 0;
                        HiddenField  hidOldRate = row.FindControl("hidOldRate") as HiddenField;
                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int         lcid = int.Parse(parentItem.GetDataKeyValue("LCID").ToString());
                        CultureInfo preInvoiceCulture = new CultureInfo(lcid);

                        if (Decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, preInvoiceCulture, out rate))
                        {
                            //decimal oldRate = 0;
                            //oldRate = decimal.Parse(hidOldRate.Value);

                            // Only apply the rate change if the rate has altered.
                            //if (oldRate != rate)
                            if (hidOldRate.Value != txtRate.Text)
                            {
                                int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                                // Update the rate (depends on item type - depends on invoice type)
                                int          preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());
                                eInvoiceType invoiceType  = (eInvoiceType)int.Parse(parentItem.GetDataKeyValue("InvoiceTypeID").ToString());
                                CultureInfo  culture      = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                                Facade.IPreInvoice    facPreInvoice = new Facade.PreInvoice();
                                Facade.IExchangeRates facER         = new Facade.ExchangeRates();

                                switch (invoiceType)
                                {
                                case eInvoiceType.ClientInvoicing:
                                    #region Client Invoice

                                    Facade.IOrder  facOrder = new Facade.Order();
                                    Entities.Order order    = facOrder.GetForOrderID(itemID);
                                    order.ForeignRate = rate;

                                    if (order.LCID != culture.LCID)
                                    {
                                        BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                                        BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                                        order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);
                                    }
                                    else
                                    {
                                        order.Rate = decimal.Round(order.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateOrderRate(preInvoiceID, itemID, order.ForeignRate, order.Rate, userName);

                                    #endregion
                                    break;

                                case eInvoiceType.SubContractorSelfBill:
                                case eInvoiceType.SubContract:
                                    #region Subby Invoicing
                                    // Needs to be Amended For Currency : TL 12/05/08;
                                    Facade.IJobSubContractor  facJSC           = new Facade.Job();
                                    Entities.JobSubContractor jobSubContractor = facJSC.GetSubContractorForJobSubContractId(itemID);
                                    jobSubContractor.ForeignRate = rate;

                                    if (jobSubContractor.LCID != culture.LCID)
                                    {
                                        jobSubContractor.Rate = facER.GetConvertedRate((int)jobSubContractor.ExchangeRateID, jobSubContractor.ForeignRate);
                                    }
                                    else
                                    {
                                        jobSubContractor.Rate = decimal.Round(jobSubContractor.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateJobSubContractRate(preInvoiceID, itemID, jobSubContractor.ForeignRate, jobSubContractor.Rate, jobSubContractor.ExchangeRateID, userName);
                                    #endregion
                                    break;

                                default:
                                    throw new NotSupportedException("You can not alter item rates on invoices of type " + invoiceType.ToString());
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
        }