public static void InitAccessLevel(int id, FormView FormView1, String dlID)
    {
        try
        {
            using (WoWiModel.WoWiEntities db = new WoWiModel.WoWiEntities())
            {
                try
                {
                    var typeList = from c in db.m_employee_accesslevel where c.employee_id== id select c;
                    foreach (WoWiModel.m_employee_accesslevel item in typeList)
                    {
                        try
                        {
                            SetTypes(item.accesslevel_id, FormView1, dlID);
                        }
                        catch (Exception)
                        {

                            //throw;
                        }

                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
        catch
        {
        }
    }
        /// <summary>
        /// Cache the associated Form View and add the actions
        /// </summary>
        /// <param name="parentSelectionFormView">Containing form</param>
        ///         
        void IFormViewControl.Initialize(FormView parentSelectionFormView)
        {
            selectionFormView = (SelectionFormView)parentSelectionFormView;

            // Add the actions
            selectionFormView.SelectionData.ActionsPaneItems.Clear();
            selectionFormView.SelectionData.ActionsPaneItems.Add(new Action("Show Selection", "Shows the Names of the selected Items in the FormView's ListView.", -1, "ShowSelection"));
        }
    protected void WACUT_AddNewItem_AddNewItem_Clicked(object sender, WAC_Event.UserControlResultEventArgs e)
    {
        FormView fv = WACGlobal_Methods.FindControl <FormView>(WACAG_FarmBusinessForm);

        if (fv != null)
        {
            WACAG_FarmBusinessForm.OpenAdd(fv);
        }
    }
Beispiel #4
0
        private void CloseFormView(ServiceRequest _request)
        {
            // should only be called from Form Control, all other controls should call ClearFormView
            WACFormControl   form = getFormFromRequest(_request);
            FormView         fv   = getFormViewFromRequest(_request);
            WACFormViewModel fvvm = (WACFormViewModel)GetViewModelForControl(form);

            fvvm.CloseFormView(form, fv);
        }
 public override void Delete(WACFormControl wfc, FormView fv, List <WACParameter> parms)
 {
     if (base.Delete <TaxParcelOwner>(parms))
     {
         // ContentStateChanged(wfc, WACFormControl.FormState.ItemDeleted);
         parms.Add(new WACParameter(string.Empty, WACFormControl.FormState.ItemDeleted, WACParameter.ParameterType.FormState));
         wfc.StateChanged(parms);
     }
 }
Beispiel #6
0
        private void bind()
        {
            D = new DemoEntities();
            var V = from O in D.OrderInfoes
                    select O;

            FormView.DataSource = V.ToList();
            FormView.DataBind();
        }
Beispiel #7
0
    public static void SetFormViewLinkButtonsImages(FormView fv)
    {
        LinkButton lbtn;

        //lbtn = (LinkButton)fv.FindControl("UpdateButton");
        //lbtn.Text = ResolveUrlImage("save.png", true);

        //lbtn = (LinkButton)fv.FindControl("UpdateCancelButton");
        //lbtn.Text = ResolveUrlImage("cancel.png", true);

        //lbtn = (LinkButton)fv.FindControl("InsertButton");
        //lbtn.Text = ResolveUrlImage("save.png", true);

        //lbtn = (LinkButton)fv.FindControl("InsertCancelButton");
        //lbtn.Text = ResolveUrlImage("cancel.png", true);

        //lbtn = (LinkButton)fv.FindControl("EditButton");
        //lbtn.Text = ResolveUrlImage("edit.png", true);

        //lbtn = (LinkButton)fv.FindControl("DeleteButton");
        //lbtn.Text = ResolveUrlImage("delete.png", true);

        //lbtn = (LinkButton)fv.FindControl("NewButton");
        //lbtn.Text = ResolveUrlImage("new.png", true);

        foreach (Control c in fv.Controls)
        {
            if (c.GetType() == typeof(LinkButton))
            {
                lbtn = (LinkButton)c;
                switch (lbtn.ID)
                {
                    case "UpdateButton":
                        lbtn.Text = ResolveUrlImage("save.png", true);
                        break;
                    case "UpdateCancelButton":
                        lbtn.Text = ResolveUrlImage("cancel.png", true);
                        break;
                    case "InsertButton":
                        lbtn.Text = ResolveUrlImage("save.png", true);
                        break;
                    case "InsertCancelButton":
                        lbtn.Text = ResolveUrlImage("cancel.png", true);
                        break;
                    case "EditButton":
                        lbtn.Text = ResolveUrlImage("edit.png", true);
                        break;
                    case "DeleteButton":
                        lbtn.Text = ResolveUrlImage("delete.png", true);
                        break;
                    case "NewButton":
                        lbtn.Text = ResolveUrlImage("new.png", true);
                        break;
                }
            }
        }
    }
Beispiel #8
0
        /// <summary>
        /// Initialize.
        /// </summary>
        /// <param name="parentSelectionFormView"></param>
        void IFormViewControl.Initialize(FormView parentSelectionFormView)
        {
            adminProperties = (AdminProperties)parentSelectionFormView;

            // Add the actions
            adminProperties.SelectionData.ActionsPaneItems.Clear();
            adminProperties.SelectionData.ActionsPaneItems.Add(new Microsoft.ManagementConsole.Action("Show Selection",
                                                                                                      "Shows the Names of the selected Items in the FormView's ListView.", -1, "ShowSelection"));
        }
        protected void UpdateAccountButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            FormView.UpdateItem();
        }
Beispiel #10
0
 public FormViewFrm(FormView formView)
     : this()
 {
     this.formView                   = formView;
     this.txtName.Text               = formView.Name;
     this.textEditorControl.Text     = formView.Code;
     this.splitContainer1.FixedPanel = FixedPanel.Panel1;
     this.splitContainer2.FixedPanel = FixedPanel.Panel2;
 }
Beispiel #11
0
 private void set_pnl(FormView view_type)
 {
     if (view_type == FormView.Служения)
     {
         pnlService.Dock       = DockStyle.Fill;
         pnlSong.Visible       = false;
         pnlMainLeft.Visible   = false;
         pnlSpevka.Visible     = false;
         pnlMainTopLeft.Height = 0;
         //btnPrint.Visible = false;
         //spSep5.Visible = false;
         lblInfo.Text       = " Служения";
         f_view             = FormView.Служения;
         pnlService.Visible = true;
     }
     else if (view_type == FormView.Спевка)
     {
         pnlMainLeft.Visible   = true;
         pnlSpevka.Dock        = DockStyle.Fill;
         pnlSong.Dock          = DockStyle.None;
         lblInfo.Text          = " Спевка";
         pnlSong.Visible       = false;
         pnlMainTopLeft.Size   = new Size(1026, 90);
         btnSearchSong.Visible = false;
         mnuSearch.Visible     = false;
         mnuAscDesc.Visible    = true;
         tvSpevka.Dock         = DockStyle.Fill;
         tvSpevka.BringToFront();
         //btnPrint.Visible = false;
         //spSep5.Visible = false;
         f_view             = FormView.Спевка;
         pnlService.Visible = false;
         pnlSpevka.Visible  = true;
     }
     else if (view_type == FormView.Песни_Ноты)
     {
         btnSearchSong.Visible = true;
         pnlSongChords.Visible = true;
         pnlMainLeft.Visible   = true;
         pnlService.Visible    = false;
         pnlSong.Visible       = true;
         pnlSong.Dock          = DockStyle.Fill;
         pnlSpevka.Visible     = false;
         pnlSpevka.Dock        = DockStyle.None;
         lblInfo.Text          = " Песни/Ноты";
         pnlMainTopLeft.Size   = new Size(1026, 0);
         mnuSearch.Visible     = true;
         mnuAscDesc.Visible    = false;
         txtSearch.Text        = "";
         tvSong.Dock           = DockStyle.Fill;
         tvSong.BringToFront();
         //btnPrint.Visible = true;
         //spSep5.Visible = true;
         f_view = FormView.Песни_Ноты;
     }
 }
Beispiel #12
0
        protected void FormView16_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            FormView f = (FormView)sender;


            m_FindControl_ddlist(FormView16, typeof(DropDownList));
            try
            {
                e.NewValues["f是否住院中"] = ddlist[0].SelectedIndex.ToString();
                e.NewValues["f鼻胃管"]   = ddlist[1].SelectedIndex.ToString();
                e.NewValues["f導尿管"]   = ddlist[2].SelectedIndex.ToString();
            }
            catch (Exception exc)
            {
            }


            //照片

            m_FindControl_Control(FormView16, typeof(FileUpload));
            fupload = (FileUpload)contrl_temp;


            m_FindControl_Control(FormView16, typeof(Image));
            img1 = ((Image)contrl_temp);
            //////

            if (fupload.HasFile)//是否有上傳的檔案
            {
                if ("jpg".Equals(fupload.FileName.Substring(fupload.FileName.LastIndexOf(".") + 1).ToLower()) ||
                    "png".Equals(fupload.FileName.Substring(fupload.FileName.LastIndexOf(".") + 1).ToLower()) ||
                    "bmp".Equals(fupload.FileName.Substring(fupload.FileName.LastIndexOf(".") + 1).ToLower()) ||
                    "gif".Equals(fupload.FileName.Substring(fupload.FileName.LastIndexOf(".") + 1).ToLower()))
                {
                    //是否符合副檔名
                    //刪除照片
                    string str_expath = System.Web.Hosting.HostingEnvironment.MapPath("~");
                    if (img1.ImageUrl.Substring(img1.ImageUrl.LastIndexOf(@"/\") + 1).ToLower()
                        != "defaultimg.png")
                    {
                        string str_temp = str_expath + img1.ImageUrl.Substring(4, img1.ImageUrl.Length - 4);
                        if (System.IO.File.Exists(str_temp))
                        {
                            System.IO.File.Delete(str_temp);
                        }
                    }
                    //上傳照片
                    fupload.SaveAs(Server.MapPath(@"~\pic\床位照片\大頭照\" + fupload.FileName));
                    e.NewValues["f照片"] = @"\.\pic\床位照片\大頭照\" + fupload.FileName;
                }
            }
            else
            {
                e.NewValues["f照片"] = img1.ImageUrl;
            }
        }
    protected void chkPayToAdd_DataBound(object sender, EventArgs e)
    {
        try
        {
            RadioButtonList chk = (RadioButtonList)sender;

            FormView frmV = (FormView)((AjaxControlToolkit.TabContainer)((AjaxControlToolkit.TabPanel)chk.NamingContainer).NamingContainer).NamingContainer;

            if (frmV.DataItem != null)
            {
                string paymode = ((DataRowView)frmV.DataItem)["paymode"].ToString();
                chk.ClearSelection();

                ListItem li = chk.Items.FindByValue(paymode);
                if (li != null)
                {
                    li.Selected = true;
                }
            }

            if (chk.SelectedItem != null)
            {
                if (chk.SelectedItem.Text == "Cheque")
                {
                    //Panel test = (Panel)frmViewAdd.FindControl("PanelBank");
                    HtmlTable table = (HtmlTable)((Panel)frmV.FindControl("tablInsert").FindControl("tabInsMain").FindControl("PanelBankAdd")).FindControl("tblBankAdd");
                    if (table != null)
                    {
                        table.Attributes.Add("class", "AdvancedSearch");
                    }
                }
                else
                {
                    HtmlTable table = (HtmlTable)((Panel)frmV.FindControl("tablInsert").FindControl("tabInsMain").FindControl("PanelBankAdd")).FindControl("tblBankAdd");

                    if (table != null)
                    {
                        table.Attributes.Add("class", "hidden");
                    }
                }
            }
            else
            {
                HtmlTable table = (HtmlTable)frmV.FindControl("tablInsert").FindControl("tabInsMain").FindControl("PanelBankAdd").FindControl("tblBankAdd");

                if (table != null)
                {
                    table.Attributes.Add("class", "hidden");
                }
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Beispiel #14
0
    protected void fvHR_WACEmployee_TrainingCost_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int?i     = null;
        int iCode = 0;

        FormView     fvHR_WACEmployee_TrainingCost = fvHR_WACEmployee_Training.FindControl("fvHR_WACEmployee_TrainingCost") as FormView;
        DropDownList ddlTrainingCostCode           = fvHR_WACEmployee_TrainingCost.FindControl("ddlTrainingCostCode") as DropDownList;
        TextBox      tbDate = fvHR_WACEmployee_TrainingCost.FindControl("AjaxCalendar_TrCostDate").FindControl("tb") as TextBox;
        TextBox      tbCost = fvHR_WACEmployee_TrainingCost.FindControl("tbCost") as TextBox;
        TextBox      tbNote = fvHR_WACEmployee_TrainingCost.FindControl("tbNote") as TextBox;

        using (WACDataClassesDataContext wac = new WACDataClassesDataContext())
        {
            try
            {
                int iFK_participantWAC_Training = Convert.ToInt32(fvHR_WACEmployee_Training.DataKey.Value);

                string trainingCostType = null;
                if (!string.IsNullOrEmpty(ddlTrainingCostCode.SelectedValue))
                {
                    trainingCostType = ddlTrainingCostCode.SelectedValue;
                }
                else
                {
                    throw new Exception("Type of Cost is required. ");
                }

                DateTime?dtDate = null;
                try { dtDate = Convert.ToDateTime(tbDate.Text); }
                catch { throw new Exception("Date missing or invalid. Date is required."); }

                decimal?dCost = null;
                try { dCost = Convert.ToDecimal(tbCost.Text); }
                catch { throw new Exception("Cost missing or invalid.  Cost is required."); }

                string sNote = null;
                if (!string.IsNullOrEmpty(tbNote.Text))
                {
                    sNote = tbNote.Text;
                }

                iCode = wac.participantWAC_trainingCost_add(iFK_participantWAC_Training, trainingCostType, dtDate, dCost, sNote, Session["userName"].ToString(), ref i);
                if (iCode == 0)
                {
                    fvHR_WACEmployee_TrainingCost.ChangeMode(FormViewMode.ReadOnly);
                    fvHR_WACEmployee_Training.ChangeMode(FormViewMode.ReadOnly);
                    BindHR_WACEmployee_Training();
                }
                else
                {
                    WACAlert.Show("Error Returned from Database.", iCode);
                }
            }
            catch (Exception ex) { WACAlert.Show("Error: " + ex.Message, 0); }
        }
    }
    protected void AccountView_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        FormView formView = sender as FormView;

        //DropDownList ddlCurrencyList = formView.FindControl("ddlCurrencyType") as DropDownList;
        //if (ddlCurrencyList.SelectedIndex == 0)
        //{
        //    e.Cancel = true;
        //}
    }
Beispiel #16
0
        public void ReturnToViewMode(WACFormControl form)
        {
            FormView fv = WACGlobal_Methods.FindControl <FormView>(form);

            fv.ChangeMode(FormViewMode.ReadOnly);
            fv.DataSource = ListSource.GetSingleItemList();
            fv.DataBind();
            ShowModal(form, true);
            ContentStateChanged(form);
        }
Beispiel #17
0
    /// <summary>
    /// Получить ClientID компонента TextBox
    /// </summary>
    /// <param name="fv"></param>
    /// <param name="Control"></param>
    /// <returns></returns>
    public string GetClientIDTextBox(FormView fv, string Control)
    {
        TextBox tb = GetTextBox(fv, Control);

        if (tb != null)
        {
            return(tb.ClientID);
        }
        return(null);
    }
Beispiel #18
0
 public void BindFormView(FormView fv, List <WACParameter> parms, MasterDetailDataObject.ItemGetterDelegate _getItem)
 {
     try
     {
         fv.DataKeyNames = ListSource.DataKeyNames;
         fv.DataSource   = ListSource.GetSingleItemList(parms, _getItem);
         fv.DataBind();
     }
     catch (Exception ex) { WACAlert.Show(ex.Message + " In " + this.ToString() + ".BindFormView", 0); }
 }
Beispiel #19
0
 protected void UpdateValidate(FormView Form, string Action, dynamic e)
 {
     //Valider unikt navn og at det er udfyldt
     Validator.ValidateUniqeness(Form, "TextBox" + Action + "EventNavn", "Events", "Navn", "Id", e, GetId());
     //Valider at tider er udfyldt korrekt
     Validator.ValidatePattern("TextBox" + Action + "EventStartTid", e, Form, @"^([0-1][0-9]|2[0-3]):([0-5][0-9])(?::([0-5][0-9]))?$", "Udfyld et tidspunkt");
     Validator.ValidatePattern("TextBox" + Action + "EventSlutTid", e, Form, @"^([0-1][0-9]|2[0-3]):([0-5][0-9])(?::([0-5][0-9]))?$", "Udfyld et tidspunkt");
     //Valider at beskrivelsen er udfyldt
     Validator.ValidateEmpty("TextBox" + Action + "EventBeskrivelse", e, Form);
 }
Beispiel #20
0
    /// <summary>
    /// Получить ClientID CheckBox
    /// </summary>
    /// <param name="fv"></param>
    /// <param name="Control"></param>
    /// <returns></returns>
    public string GetClientIDCheckBox(FormView fv, string Control)
    {
        CheckBox cb = GetCheckBox(fv, Control);

        if (cb != null)
        {
            return(cb.ClientID);
        }
        return(null);
    }
Beispiel #21
0
    /// <summary>
    /// Получить значение Value(int?) из DropDownList с учетом значения по умолчанию
    /// </summary>
    /// <param name="fv"></param>
    /// <param name="Control"></param>
    /// <param name="null_value"></param>
    /// <returns></returns>
    public int?GetValueDropDownList(FormView fv, string Control, int?null_value)
    {
        string res = GetValueDropDownList(fv, Control);

        if (res != null)
        {
            int.Parse(res);
        }
        return(null_value);
    }
Beispiel #22
0
    /// <summary>
    /// Установить активность компонента
    /// </summary>
    /// <param name="fv"></param>
    /// <param name="Control"></param>
    /// <param name="enable"></param>
    public void SetEnableDropDownList(FormView fv, string Control, bool enable)
    {
        DropDownList ddl;

        ddl = GetDropDownList(fv, Control);
        if (ddl != null)
        {
            ddl.Enabled = enable;
        }
    }
Beispiel #23
0
 public static DecisionPoint CreateDecisionPoint(
     Task task, string name,
     DecisionMethod decisionMethod,
     string variableName           = null,
     int repetitionFrequenceByHour = 1,
     string description            = null,
     FormView formView             = null)
 {
     return(new DecisionPoint(task, name, decisionMethod, variableName, repetitionFrequenceByHour, description, formView));
 }
 public static void BindFormView(FormView gvw, DataTable dt)
 {
     try
     {
         gvw.DataSource = dt;
         gvw.DataBind();
         gvw.EmptyDataText = "No Mails Found Yet";
     }
     catch { }
 }
Beispiel #25
0
 public void CloseFormView(WACFormControl form, FormView fv)
 {
     fv.ChangeMode(FormViewMode.ReadOnly);
     fv.DataSource = null;
     fv.DataBind();
     form.CurrentState = WACFormControl.FormState.Closed;
     ShowModal(form, false);
     CloseControls(form);
     ContentStateChanged(form);
 }
Beispiel #26
0
    /// <summary>
    /// Получить ClientID DropDownList
    /// </summary>
    /// <param name="fv"></param>
    /// <param name="Control"></param>
    /// <returns></returns>
    public string GetClientIDDropDownList(FormView fv, string Control)
    {
        DropDownList ddl = GetDropDownList(fv, Control);

        if (ddl != null)
        {
            return(ddl.ClientID);
        }
        return(null);
    }
Beispiel #27
0
    protected void fmvAircraft_DataBound(object sender, EventArgs e)
    {
        if (sender == null)
        {
            throw new ArgumentNullException(nameof(sender));
        }
        FormView fv = sender as FormView;

        BindAircraftImages(fv.FindControl("mfbHoverImageList"));
    }
    protected void lbSA_TaxParcel_Insert_Click(object sender, EventArgs e)
    {
        FormView fv = fvSA.FindControl("fvSA_TaxParcel") as FormView;

        if (WACGlobal_Methods.Security_UserCanPerformAction(Session["userID"], "I", "A", "supplementalAgreementTaxParcel", "msgInsert"))
        {
            fv.ChangeMode(FormViewMode.Insert);
            Populate_SA_TaxParcel_FormView(fv, -1);
        }
    }
Beispiel #29
0
        void IFormViewControl.Initialize(FormView parentSelectionFormView)
        {
            _formView = (SolutionUsersFormView)parentSelectionFormView;
            _formView.SelectionData.ActionsPaneItems.Clear();
            _serverDto = GetServerDto();

            var ssoSolutionUsersNode = _formView.ScopeNode as SolutionUsersNode;
            _auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(_serverDto, ssoSolutionUsersNode.TenantName);
            RefreshUsers(string.Empty);
        }
Beispiel #30
0
        protected void LinkButtonAddNewBook_Click(object sender, EventArgs e)
        {
            LinkButton LinkButtonAddNewBook = UpdatePanelCreate.FindControl("LinkButtonAddNewBook") as LinkButton;

            LinkButtonAddNewBook.Visible = false;

            FormView FormViewCreate = UpdatePanelCreate.FindControl("FormViewCreate") as FormView;

            FormViewCreate.Visible = true;
        }
 private void Populate_SA_Note_FormView(FormView fv, int i)
 {
     using (WACDataClassesDataContext wac = new WACDataClassesDataContext())
     {
         var a = wac.supplementalAgreementNotes.Where(w => w.pk_supplementalAgreementNote == i).Select(s => s);
         fv.DataKeyNames = new string[] { "pk_supplementalAgreementNote" };
         fv.DataSource   = a;
         fv.DataBind();
     }
 }
Beispiel #32
0
 public static Condition CreateCondition(
     Task task,
     string name,
     ProjectRole assignedRole,
     string variableName = null,
     string description  = null,
     FormView formView   = null)
 {
     return(new Condition(task, name, assignedRole, variableName, description, formView));
 }
 public static void SetTypes(int id, FormView FormView1, String dlID)
 {
     CheckBoxList list = (CheckBoxList)FormView1.FindControl(dlID);
     foreach (ListItem item in list.Items)
     {
         if (item.Value == id + "")
         {
             item.Selected = true;
             break;
         }
     }
 }
 public static void StoreDatasInViewState(FormView fv, String ID, StateBag ViewState, String ViewStateKey)
 {
     List<int> roles = new List<int>();
     CheckBoxList list = (CheckBoxList)fv.FindControl(ID);
     foreach (ListItem item in list.Items)
     {
         if (item.Selected)
         {
             roles.Add(int.Parse(item.Value));
         }
     }
     ViewState[ViewStateKey] = roles;
 }
 public static void InitRoles(int id, FormView FormView1,String dlID)
 {
     try
     {
         using (WoWiModel.WoWiEntities db = new WoWiModel.WoWiEntities())
         {
             try
             {
                 var roleList = from c in db.m_contact_role where c.contact_id == id select c;
                 foreach (WoWiModel.m_contact_role item in roleList)
                 {
                     Utils.SetCheckBoxListValues(item.role_id, FormView1, dlID);
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     catch
     {
     }
 }
 public static void InitTechnologyData(int id, FormView FormView1, String dlID)
 {
     try
     {
         using (WoWiModel.WoWiEntities db = new WoWiModel.WoWiEntities())
         {
             try
             {
                 var typeList = from c in db.m_clientappliant_technology where c.clientappliant_id == id select c;
                 foreach (WoWiModel.m_clientappliant_technology item in typeList)
                 {
                     SetTypes(item.technology_id, FormView1, dlID);
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     catch
     {
     }
 }
 //method checks if the package dates are viable for given formview
 //if dates are not valid, they are highlighted in red
 private static bool CheckDates(FormView currentForm)
 {
     //declare a bool to keep track if the dates are valid
     //presume dates are valid, set it to true
     bool validDates = true;
     //get the Start Date from the formview
     string date = ((Label)currentForm.FindControl("PkgStartDateLabel")).Text;
     //get today's date and save into today variable
     DateTime startDate = Convert.ToDateTime(date);
     DateTime today = DateTime.Today;
     //comapre dates
     int result = DateTime.Compare(startDate, today);
     if (result < 0) //startDate is earlier than today
     //highlight the date red
     {
         Label lbl = (Label)currentForm.FindControl("PkgStartDateLabel");
         //assign css class that has font set to red
         lbl.CssClass = "changeFont";
         validDates = false;
     }
     date = ((Label)currentForm.FindControl("PkgEndDateLabel")).Text;
     DateTime endDate = Convert.ToDateTime(date);
     result = DateTime.Compare(endDate, today);
     if (result < 0) //endDate is earlier than today
     //highlight the date red
     {
         Label lbl = (Label)currentForm.FindControl("PkgEndDateLabel");
         //assign css class that has font set to red
         lbl.CssClass = "changeFont";
         validDates = false;
     }
     return validDates;
 }
Beispiel #38
0
 public static void SetDropDownListValue(FormView fv, String ID, String value)
 {
     DropDownList dl = (DropDownList)fv.FindControl(ID);
     dl.SelectedValue = value;
 }
 protected void setFormData(FormView fvName, FormViewMode fvMode, Object obj)
 {
     fvName.ChangeMode(fvMode);
     fvName.DataSource = obj;
     fvName.DataBind();
 }
Beispiel #40
0
    /// <summary>
    /// Cool function I created to autogenerate a registration form using the name of the SQL table, the name of the form view and the data.
    /// </summary>
    /// <param name="strTableName"></param>
    /// <param name="fv"></param>
    /// <param name="dt"></param>
    /// <param name="strReadOnlyFields"></param>
    /// <param name="intMode"></param>
    protected void AutoGenerateFormUserControlsForFormView(string strTableName, FormView fv, DataTable dt, ArrayList strReadOnlyFields, Int16 intMode, ArrayList strChangedFields, ArrayList strToolTip, string strKeyValue)
    {
        //get all column names we want to search on
        StringBuilder sb = new StringBuilder();
        String strTemp = String.Empty;
        for (int j = 0; j < dt.Columns.Count; j++)
        {
            sb.AppendFormat("'{0}',", dt.Columns[j].ColumnName);
        }
        if (sb.Length > 0) sb.Length--;

        String strSQL = String.Format(@"
            SELECT name, xtype, length
            FROM syscolumns
            WHERE ID IN (
                SELECT ID
                FROM sysobjects
                WHERE Name = '{0}'
            ) {1}
            ORDER BY colorder",
                strTableName,
                sb.Length > 0 ? "AND name IN (" + sb.ToString() + ")" : String.Empty
                );

        DataTable dtCols = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable(strSQL);
        int i = 0;

        Table t = new Table();

        foreach (DataRow dr in dtCols.Rows)
        {
            TableRow tr = new TableRow();
            TableCell tc1 = new TableCell();
            TableCell tc2 = new TableCell();

            #region Label Of Control
            Label lblTemp = new Label();
            lblTemp.Text = (string)dr[0];
            if (strChangedFields.Contains(lblTemp.Text))
            {
                lblTemp.Font.Bold = true;
                lblTemp.ForeColor = System.Drawing.Color.Red;
                lblTemp.Font.Size = 12;
                lblTemp.ToolTip = Convert.ToString(strToolTip[strChangedFields.IndexOf(lblTemp.Text)]);
            }

            tc1.Controls.Add(lblTemp);
            #endregion

            switch (Convert.ToInt32(dr[1]))
            {
                case (int)FieldType.StringOrText:

                    TextBox txtTemp = new TextBox();
                    txtTemp.Text = Convert.ToString(dt.Rows[0][i]);
                    txtTemp.MaxLength = Convert.ToInt32(dr[2]);

                    if (txtTemp.MaxLength > 100)
                    {
                        txtTemp.TextMode = TextBoxMode.MultiLine;
                        txtTemp.Width = 400;
                        txtTemp.Height = 100;
                    }
                    else
                    {
                        txtTemp.Width = txtTemp.MaxLength * 2;
                    }

                    txtTemp.Enabled = !strReadOnlyFields.Contains(lblTemp.Text) && (intMode != (int)Mode.ReadOnly);    //disable any read-only fields

                    tc2.Controls.Add(txtTemp);
                    break;

                case (int)FieldType.Integer:
                case (int)FieldType.UniqueIdentifier:

                    TextBox txtTemp2 = new TextBox();
                    txtTemp2.Text = Convert.ToString(dt.Rows[0][i]);
                    txtTemp2.MaxLength = 10;
                    txtTemp2.Enabled = !strReadOnlyFields.Contains(lblTemp.Text) && (intMode != (int)Mode.ReadOnly);    //disable any read-only fields

                    tc2.Controls.Add(txtTemp2);
                    break;

                default:
                    break;
            }

            HiddenField hdnTemp = new HiddenField(); //store the old value
            hdnTemp.ID = lblTemp.Text + "_OldValue";
            hdnTemp.Value = Convert.ToString(dt.Rows[0][i]);
            tc2.Controls.Add(hdnTemp);

            tr.Controls.Add(tc1);
            tr.Controls.Add(tc2);
            t.Controls.Add(tr);

            i++;
        }

        fv.Controls.Add(t);

        //if (intMode == (int)Mode.ReadOnly)
        //{
        //    Button btnUpdate1 = new Button();
        //    btnUpdate1.ID = "btnUpdate";
        //    btnUpdate1.Text = "Confirm Changes";
        //    btnUpdate1.CommandName = "Confirm";
        //    btnUpdate1.CommandArgument = strKeyValue;
        //    btnUpdate1.Command += new EventHandler(btnUpdate_Click);
        //    fv.Controls.Add(btnUpdate1);

        //    ConfirmButtonExtender cbeConfirm = new ConfirmButtonExtender();
        //    cbeConfirm.ConfirmText = "Please confirm that you have reviewed all your changes.  Once you confirm, these changes will be removed from your Review Changes list.";
        //    cbeConfirm.TargetControlID = "btnUpdate";
        //    fv.Controls.Add(cbeConfirm);
        //}
    }
Beispiel #41
0
 public static String GetDropDownListSelectedValue(FormView fv, String ID)
 {
     DropDownList dl = (DropDownList)fv.FindControl(ID);
     return dl.SelectedValue;
 }
    protected void setFormData(FormView fvName, FormViewMode fvMode, Object obj)
    {
        fvName.ChangeMode(fvMode);
        fvName.DataSource = obj;
        fvName.DataBind();

        //set kind ddl
        switch (fvMode)
        {
            case FormViewMode.Insert:
                setDdlMCodeList(fvName, "ddlMCode");
                //read only selected date
                TextBox tbPurDate = (TextBox)fvMaterialRegList.FindControl("tbPurDate");
                tbPurDate.Attributes.Add("readonly", "readonly");
                break;
            case FormViewMode.Edit:
                setDdlMCodeList(fvName, "ddlMCodeE");
                //read only selected date
                TextBox tbPurDateE = (TextBox)fvMaterialRegList.FindControl("tbPurDateE");
                tbPurDateE.Attributes.Add("readonly", "readonly");
                break;
        }
    }
Beispiel #43
0
 public static String GetTextBoxValue(FormView fv, String ID)
 {
     TextBox tb = (TextBox)fv.FindControl(ID);
     return tb.Text;
 }
Beispiel #44
0
    //-------------------------------------------------------------------------------------------
    private void AddControl(Random rnd)
    {
        int x = rnd.Next(10000);

               //EntityDataSource eds = new EntityDataSource();
               //eds.ID = "DetailsDataSource" + x.ToString();
               //eds.EnableUpdate = true;
               //eds.EntityTypeFilter = table.EntityType.Name;

               ////eds.EntitySetName = "Accounting_Accounts";
               ////eds.ContextTypeName = "WeavverEntityContext";
               ////eds.Where = "it.id = @id";
               ////eds.WhereParameters.Add("id", DbType.Guid, "3d322c57-2b4a-4b27-8187-2094931eb2ca");
               //AddedControls.Controls.Add(eds);

               //DynamicDataManager ddm = new DynamicDataManager();
               //ddm.ID = "DynamicDataManager3";
               //ddm.AutoLoadForeignKeys = true;
               //DataControlReference ddr = new DataControlReference();
               //ddr.ControlID = "FormView3";
               //ddm.DataControls.Add(ddr);

               //AddedControls.Controls.Add(ddm);

               FormView fv = new FormView();
               fv.ID = "FormView" + x.ToString();
               fv.DataSourceID = "GridDataSource";
               YourTemplate yt = new YourTemplate();
               fv.ItemTemplate = yt;

               //fv.ItemTemplate.Controls.Add(de);

               AddedControls.Controls.Add(fv);

               DynamicDataManager1.RegisterControl(fv);

               EntityControls.Update();
    }
 protected void setDdlList(FormView fvName, string ddlName, string cText, string dSelect)
 {
     DropDownList ddlList = (DropDownList)fvName.FindControl(ddlName);
     DataMaster dLocal = new DataMaster();
     dLocal = serviceMaster.ActionDataMaster(cText, dLocal, 21);
     switch(cText)
     {
       case "kind":
           ddlList.DataSource = dLocal.KindList;
           ddlList.DataTextField = "KName";
           ddlList.DataValueField = "KIDX";
           break;
       case "asset":
           ddlList.DataSource = dLocal.AssetList;
           ddlList.DataTextField = "AsName";
           ddlList.DataValueField = "AsIDX";
           break;
       case "materialtype":
           ddlList.DataSource = dLocal.MaterialTypeList;
           ddlList.DataTextField = "TypeName";
           ddlList.DataValueField = "TypeIDX";
           break;
       case "unit":
           ddlList.DataSource = dLocal.UnitList;
           ddlList.DataTextField = "UnitName";
           ddlList.DataValueField = "UnitIDX";
           break;
     }
     ddlList.DataBind();
     //ddlList.Items.Insert(0, new ListItem("-- Select Kind --", "0"));
     ddlList.SelectedValue = dSelect;
 }
Beispiel #46
0
 public static void SetCheckBoxListValues(int id, FormView FormView1, String dlID)
 {
     SetCheckBoxListValues(id + "", FormView1, dlID);
 }
Beispiel #47
0
    private void SetDefaultValue(FormView frmView)
    {
        if (frmView.CurrentMode == FormViewMode.Edit || frmView.CurrentMode == FormViewMode.Insert)
        {
            AssetUtility Util = new AssetUtility();
            string currDate = DateTime.Now.ToString();

            TextBox UpdatedByTxb = frmView.FindControl("UpdatedByTxb") as TextBox;
            TextBox UpdatedAtTxb = frmView.FindControl("UpdatedAtTxb") as TextBox;
            TextBox TimeOfRecordingADocumentTxb = frmView.FindControl("TimeOfRecordingADocumentTxb") as TextBox;

            UpdatedByTxb.Text = Util.GetUserFullLogin().ToString();
            UpdatedAtTxb.Text = currDate;
            if (frmView.CurrentMode == FormViewMode.Insert) {
                TextBox CreatedByTxb = frmView.FindControl("CreatedByTxb") as TextBox;
                TextBox CreatedAtTxb = frmView.FindControl("CreatedAtTxb") as TextBox;
                CreatedByTxb.Text = Util.GetUserFullLogin().ToString();
                CreatedAtTxb.Text = currDate;
                TimeOfRecordingADocumentTxb.Text = currDate;
            }
        }
    }
    protected void setFormData(FormView fvName, FormViewMode fvMode, Object obj)
    {
        fvName.ChangeMode(fvMode);
        fvName.DataSource = obj;
        fvName.DataBind();

        //set kind ddl
        switch (fvMode)
        {
            case FormViewMode.Insert:
                setDdlList(fvName, "ddlKIDX", "kind", "3");
                setDdlList(fvName, "ddlAsIDX", "asset", "1");
                setDdlList(fvName, "ddlTypeIDX", "materialtype", "1");
                setDdlList(fvName, "ddlUnitIDX", "unit", "1");
                break;
            case FormViewMode.Edit:
                HiddenField typeIDX = (HiddenField)fvName.FindControl("hfTypeIDXE");
                HiddenField unitIDX = (HiddenField)fvName.FindControl("hfUnitIDXE");
                HiddenField kIDX = (HiddenField)fvName.FindControl("hfKIDXE");
                HiddenField asIDX = (HiddenField)fvName.FindControl("hfAsIDXE");
                setDdlList(fvName, "ddlKIDXE", "kind", kIDX.Value);
                setDdlList(fvName, "ddlAsIDXE", "asset", asIDX.Value);
                setDdlList(fvName, "ddlTypeIDXE", "materialtype", typeIDX.Value);
                setDdlList(fvName, "ddlUnitIDXE", "unit", unitIDX.Value);
                break;
        }
    }
 protected void setDdlMCodeList(FormView fvName, string ddlName)
 {
     DropDownList ddlList = (DropDownList)fvName.FindControl(ddlName);
     DataMaster dLocal = new DataMaster();
     dLocal = serviceMaster.ActionDataMaster("materialreg", dLocal, 22);
     ddlList.DataSource = dLocal.MaterialRegisterList;
     ddlList.DataTextField = "CMCode";
     ddlList.DataValueField = "RegIDX";
     ddlList.DataBind();
     ddlList.Items.Insert(0, new ListItem("-- Mat. Code | S/N --", "-1"));
 }
Beispiel #50
0
        public void Interprete(FormView formview)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("(function(){");
            string select_parameters_guid = "_" + Guid.NewGuid().ToString().Replace("-", string.Empty);
            string update_parameters_guid = "_" + Guid.NewGuid().ToString().Replace("-", string.Empty);
            string create_parameters_guid = "_" + Guid.NewGuid().ToString().Replace("-", string.Empty);
            string delete_parameters_guid = "_" + Guid.NewGuid().ToString().Replace("-", string.Empty);
            sb.AppendFormat("var {0} = new Array();", select_parameters_guid);
            sb.AppendFormat("var {0} = new Array();", update_parameters_guid);
            sb.AppendFormat("var {0} = new Array();", create_parameters_guid);
            sb.AppendFormat("var {0} = new Array();", delete_parameters_guid);

            if (formview.DataBinder != null)
            {
                if (formview.DataBinder.SelectCommand != null && !string.IsNullOrWhiteSpace(formview.DataBinder.SelectCommand.Parameters))
                {
                    string[] parameters = formview.DataBinder.SelectCommand.Parameters.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
                    foreach (string s in parameters)
                        sb.AppendFormat("{0}.push(\"{1}\");", select_parameters_guid, s);
                }
                if (formview.DataBinder.UpdateCommand != null && !string.IsNullOrWhiteSpace(formview.DataBinder.UpdateCommand.Parameters))
                {
                    string[] parameters = formview.DataBinder.UpdateCommand.Parameters.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
                    foreach (string s in parameters)
                        sb.AppendFormat("{0}.push(\"{1}\");", update_parameters_guid, s);
                }
                if (formview.DataBinder.CreateCommand != null && !string.IsNullOrWhiteSpace(formview.DataBinder.CreateCommand.Parameters))
                {
                    string[] parameters = formview.DataBinder.CreateCommand.Parameters.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
                    foreach (string s in parameters)
                        sb.AppendFormat("{0}.push(\"{1}\");", create_parameters_guid, s);
                }
                if (formview.DataBinder.DeleteCommand != null && !string.IsNullOrWhiteSpace(formview.DataBinder.DeleteCommand.Parameters))
                {
                    string[] parameters = formview.DataBinder.DeleteCommand.Parameters.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
                    foreach (string s in parameters)
                        sb.AppendFormat("{0}.push(\"{1}\");", delete_parameters_guid, s);
                }
            }

            sb.Append("return new Dat.V1.Controls.FormView({");
            sb.AppendFormat("ID: \"{0}\",", formview.ID);
            sb.AppendFormat("TagName: \"{0}\",", formview.TagName);
            sb.AppendFormat("TemplateName: \"{0}\",", formview.TemplateName);
            if (!string.IsNullOrWhiteSpace(formview.DataItemSchema))
                sb.Append("DataItemSchema: \"(function(){return " + formview.DataItemSchema + ";})();\",");

            if (!string.IsNullOrWhiteSpace(formview.FilterElement))
                sb.AppendFormat("FilterElement: {0},", formview.FilterElement);

            if (!string.IsNullOrWhiteSpace(formview.SubmitElement))
                sb.AppendFormat("SubmitElement: \"{0}\",", formview.SubmitElement);

            if (!string.IsNullOrWhiteSpace(formview.DeleteElement))
                sb.AppendFormat("DeleteElement: \"{0}\",", formview.DeleteElement);

            sb.AppendFormat("Container: \"{0}\",", string.IsNullOrWhiteSpace(formview.ContainerElement) ? "#Dat" : formview.ContainerElement);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnFieldBound))
                sb.AppendFormat("OnFieldBound: eval({0}),", formview.Events.OnFieldBound);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnFieldBinding))
                sb.AppendFormat("OnFieldBinding: eval({0}),", formview.Events.OnFieldBinding);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnDataBinding))
                sb.AppendFormat("OnDataBinding: eval({0}),", formview.Events.OnDataBinding);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnDataBound))
                sb.AppendFormat("OnDataBound: eval({0}),", formview.Events.OnDataBound);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnHeaderInitialized))
                sb.AppendFormat("OnHeaderInitialized: eval({0}),", formview.Events.OnHeaderInitialized);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnFooterInitialized))
                sb.AppendFormat("OnFooterInitialized: eval({0}),", formview.Events.OnFooterInitialized);

            if (!string.IsNullOrWhiteSpace(formview.OnReady))
                sb.AppendFormat("OnReady: eval({0}),", formview.OnReady);

            if (!string.IsNullOrWhiteSpace(formview.Events.OnItemCommand))
                sb.AppendFormat("OnItemCommand: eval({0}),", formview.Events.OnItemCommand);

            if (!string.IsNullOrWhiteSpace(formview.OnError))
                sb.AppendFormat("OnError: eval({0}),", formview.OnError);

            if (!string.IsNullOrWhiteSpace(formview.OnInitialized))
                sb.AppendFormat("OnInit: eval({0}),", formview.OnInitialized);

            if (formview.DataBinder != null)
            {
                sb.Append("DataBinder: {");
                sb.AppendFormat("AssetName: \"{0}\",", formview.DataBinder.AssetName);
                sb.AppendFormat("PageSize: {0},", formview.DataBinder.PageSize);
                sb.AppendFormat("FreezeMode: {0},", (formview.DataBinder.Interval < 1).ToString().ToLower());
                if (formview.DataBinder.Interval > 0)
                    sb.AppendFormat("Interval: {0},", formview.DataBinder.Interval);
                sb.AppendFormat("StartIndex: {0},", formview.DataBinder.StartIndex);

                if (!string.IsNullOrWhiteSpace(formview.DataBinder.PrimaryKey))
                    sb.AppendFormat("PrimaryKey: \"{0}\",", formview.DataBinder.PrimaryKey);

                if (!string.IsNullOrWhiteSpace(formview.DataBinder.OnError))
                    sb.AppendFormat("OnError: eval({0}),", formview.DataBinder.OnError);

                if (formview.DataBinder.SelectCommand != null)
                {
                    sb.AppendFormat("SelectCommand: \"{0}\",", formview.DataBinder.SelectCommand.Target);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.SelectCommand.OnExecuting))
                        sb.AppendFormat("OnSelecting: eval({0}),", formview.DataBinder.SelectCommand.OnExecuting);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.SelectCommand.OnExecuted))
                        sb.AppendFormat("OnSelected: eval({0}),", formview.DataBinder.SelectCommand.OnExecuted);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.SelectCommand.DataItemPropertyName))
                        sb.AppendFormat("SelectDataItemProperty: \"{0}\",", formview.DataBinder.SelectCommand.DataItemPropertyName);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.SelectCommand.Parameters))
                        sb.AppendFormat("SelectParameters: {0},", select_parameters_guid);

                }
                if (formview.DataBinder.UpdateCommand != null)
                {
                    sb.AppendFormat("UpdateCommand: \"{0}\",", formview.DataBinder.UpdateCommand.Target);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.UpdateCommand.OnExecuting))
                        sb.AppendFormat("OnUpdating: eval({0}),", formview.DataBinder.UpdateCommand.OnExecuting);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.UpdateCommand.OnExecuted))
                        sb.AppendFormat("OnUpdated: eval({0}),", formview.DataBinder.UpdateCommand.OnExecuted);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.UpdateCommand.DataItemPropertyName))
                        sb.AppendFormat("UpdateDataItemProperty: \"{0}\",", formview.DataBinder.UpdateCommand.DataItemPropertyName);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.UpdateCommand.Parameters))
                        sb.AppendFormat("UpdateParameters: {0},", update_parameters_guid);
                }
                if (formview.DataBinder.DeleteCommand != null)
                {
                    sb.AppendFormat("DeleteCommand: \"{0}\",", formview.DataBinder.DeleteCommand.Target);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.DeleteCommand.OnExecuting))
                        sb.AppendFormat("OnDeleting: eval({0}),", formview.DataBinder.DeleteCommand.OnExecuting);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.DeleteCommand.OnExecuted))
                        sb.AppendFormat("OnDeleted: eval({0}),", formview.DataBinder.DeleteCommand.OnExecuted);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.DeleteCommand.DataItemPropertyName))
                        sb.AppendFormat("DeleteDataItemProperty: \"{0}\",", formview.DataBinder.DeleteCommand.DataItemPropertyName);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.DeleteCommand.Parameters))
                        sb.AppendFormat("DeleteParameters: {0},", delete_parameters_guid);
                }
                if (formview.DataBinder.CreateCommand != null)
                {
                    sb.AppendFormat("CreateCommand: \"{0}\",", formview.DataBinder.CreateCommand.Target);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.CreateCommand.OnExecuting))
                        sb.AppendFormat("OnCreating: eval({0}),", formview.DataBinder.CreateCommand.OnExecuting);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.CreateCommand.OnExecuted))
                        sb.AppendFormat("OnCreated: eval({0}),", formview.DataBinder.CreateCommand.OnExecuted);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.CreateCommand.DataItemPropertyName))
                        sb.AppendFormat("CreateDataItemProperty: \"{0}\",", formview.DataBinder.CreateCommand.DataItemPropertyName);

                    if (!string.IsNullOrWhiteSpace(formview.DataBinder.CreateCommand.Parameters))
                        sb.AppendFormat("CreateParameters: {0},", create_parameters_guid);
                }
                sb.Append("},");
            }

            string script = sb.ToString().Trim(',').Trim() + "});";
            script += "})();";
            ControlScripts.Append(script);
        }
    protected void setDdlSiteList(FormView fvName, string ddlName, int selectType)
    {
        DropDownList ddlList = (DropDownList)fvName.FindControl(ddlName);
        DataMaster dLocal = new DataMaster();
        dLocal = serviceMaster.ActionDataMaster("site", dLocal, 22);

        switch (selectType)
        {
            case 1: //bangping only
                var linq1 = from s
                            in dLocal.SiteList
                            where s.SiteCode.Contains("1031") || s.SiteCode.Contains("1032") || s.SiteCode.Contains("1033")
                            select s;
                ddlList.DataSource = linq1.ToList();
                break;
            case 2: //exception bangping
                var linq2 = from s
                            in dLocal.SiteList
                            where !s.SiteCode.Contains("1031") && !s.SiteCode.Contains("1032") && !s.SiteCode.Contains("1033")
                            select s;
                ddlList.DataSource = linq2.ToList();
                break;
        }
        //ddlList.DataSource = linqData.ToList(); //dLocal.SiteList;
        ddlList.DataTextField = "SiteCodeName";
        ddlList.DataValueField = "SiteIDX";
        ddlList.DataBind();
        ddlList.Items.Insert(0, new ListItem("-- Project --", "-1"));

        if (selectType == 1) //default for bangping
        {
            ddlList.SelectedIndex = 1;
        }
    }
    protected void setFormData(FormView fvName, FormViewMode fvMode, Object obj)
    {
        fvName.ChangeMode(fvMode);
        fvName.DataSource = obj;
        fvName.DataBind();

        //set kind ddl
        switch (fvMode)
        {
            case FormViewMode.Insert:
                switch (recStatus)
                {
                    case 100000:
                        setDdlSiteList(fvName, "ddlFromSiteList", 1);
                        setDdlSiteList(fvName, "ddlToSiteList", 2);
                        //create order no.
                        var culture = new System.Globalization.CultureInfo("en-US");
                        string curYear = DateTime.Now.ToString("yy", culture);
                        string curMonth = DateTime.Now.ToString("MM");
                        var orderNum = "001";
                        //get max of order no.
                        DataMaster dataTempGv = (DataMaster)ViewState["dataRecord"];
                        if (dataTempGv.MaterialRecordList != null)
                        {
                            var tData = dataTempGv.MaterialRecordList;
                            try{
                                var linqMaxOrder = (from m in tData
                                                where m.RecNo.StartsWith(curYear + curMonth) && m.RecStatus == 100000
                                                orderby m.RecNo descending
                                                select m.RecNo).FirstOrDefault();//m.RecNo).Max(); //.FirstOrDefault();

                            orderNum = (int.Parse(linqMaxOrder.Substring(4)) + 1).ToString("D3");
                            } catch {
                                orderNum = "001";
                            }

                            //litTest.Text = HttpUtility.HtmlDecode(funcWeb.ConvertObjectToXml(dataTempGv));
                        }

                        TextBox tbOrderNo = (TextBox)fvName.FindControl("tbOrderNo");
                        tbOrderNo.Text = curYear + curMonth + orderNum;
                        tbOrderNo.ReadOnly = true;
                        break;
                    case 800000:
                        setDdlSiteList(fvName, "ddlFromSiteList", 2);
                        setDdlSiteList(fvName, "ddlToSiteList", 1);
                        break;
                }
                //One way to fix this is to modify our LINQ to XML query so that we indicate that YearsAtCompany is a nullable integer.  We can do this by changing the explicit cast to be (int?) instead of (int)
                ////read only selected date
                //TextBox tbOrderCreate = (TextBox)fvName.FindControl("tbOrderCreate");
                //tbOrderCreate.Attributes.Add("readonly", "readonly");
                //material code
                setDdlMCodeList(fvName, "ddlMCode");
                break;
            case FormViewMode.Edit:
                if (ViewState["vsItemLists"] != null)
                {
                    GridView gvMaterialItemList = (GridView)fvName.FindControl("gvMaterialItemList");
                    gvMaterialItemList.DataSource = ((DataMaster)ViewState["vsItemLists"]).MaterialRecordItemList;
                    gvMaterialItemList.DataBind();
                }
                break;
        }
    }
Beispiel #53
0
 public static void SetTextBoxValue(FormView fv, String ID, String value)
 {
     TextBox tb = (TextBox)fv.FindControl(ID);
     tb.Text = value;
 }
    protected void setFormData(FormView fvName, FormViewMode fvMode, Object obj)
    {
        fvName.ChangeMode(fvMode);
        fvName.DataSource = obj;
        fvName.DataBind();

        //set data
        switch (fvMode)
        {
            case FormViewMode.Insert:
                break;
            case FormViewMode.Edit:
                Label lblTypeIDXE = (Label)fvName.FindControl("lblTypeIDXE");
                TextBox tbName = (TextBox)fvTypeList.FindControl("tbName");
                TextBox tbDesc = (TextBox)fvTypeList.FindControl("tbDesc");
                DropDownList ddlStatusE = (DropDownList)fvName.FindControl("ddlStatusE");
                switch (matType)
                {
                    case "kind":
                        DetailKindList[] tmpK = (DetailKindList[])obj;
                        lblTypeIDXE.Text = tmpK[0].KIDX.ToString();
                        tbName.Text = tmpK[0].KName;
                        tbDesc.Text = tmpK[0].KDesc;
                        ddlStatusE.SelectedValue = tmpK[0].KStatus.ToString();
                        break;
                    case "asset":
                        DetailAssetList[] tmpA = (DetailAssetList[])obj;
                        lblTypeIDXE.Text = tmpA[0].AsIDX.ToString();
                        tbName.Text = tmpA[0].AsName;
                        tbDesc.Text = tmpA[0].AsDesc;
                        ddlStatusE.SelectedValue = tmpA[0].AsStatus.ToString();
                        break;
                }
                break;
        }
    }