예제 #1
0
 partial void Deletelsttbl_Dashboard(lsttbl_Dashboard instance);
예제 #2
0
        public void Save_Dashboard(lsttbl_Dashboard info)
        {
            var db = GlobalVar.DbBI;
            try
            {
                var objFound = db.lsttbl_Dashboards.FirstOrDefault(p => p.Code == info.Code);
                if (objFound == null)
                    db.lsttbl_Dashboards.InsertOnSubmit(info);
                else
                    objFound.UpdateOnSubmit(info);

                db.SubmitChanges();
            }
            catch { }
        }
예제 #3
0
 partial void Updatelsttbl_Dashboard(lsttbl_Dashboard instance);
예제 #4
0
 partial void Insertlsttbl_Dashboard(lsttbl_Dashboard instance);
예제 #5
0
        public void Save_Dashboard(lsttbl_Dashboard info)
        {
            var db = GlobalVar.DbBI;
            try
            {
                System.Data.Linq.Table<lsttbl_Dashboard> dashboards = db.lsttbl_Dashboards;
                var objFound = dashboards.FirstOrDefault(p => p.Code == info.Code);
                if (objFound == null)
                {
                    db.lsttbl_Dashboards.InsertOnSubmit(info);
                }
                else
                {
                    objFound.UpdateOnSubmit(info);
                }
                // update IsDefault
                if (info.IsDefault)
                {
                    foreach (lsttbl_Dashboard tbl in dashboards)
                    {
                        if (tbl.Code == info.Code) { continue; }
                        tbl.IsDefault = false;
                    }
                }

                db.SubmitChanges();
            }
            catch { }
        }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DashboardDefine dbDefine = new DashboardDefine()
            {
                DisplayName = txtDashboardName.Text
            };
            // detect template
            if (FourPane_1.Checked)
            {
                dbDefine.Template = "FourPane_1";
            }
            else if (TwoPane_2.Checked)
            {
                dbDefine.Template = "TwoPane_2";
            }
            else if (ThreePane_1.Checked)
            {
                dbDefine.Template = "ThreePane_1";
            }
            else if (ThreePane_2.Checked)
            {
                dbDefine.Template = "ThreePane_2";
            }
            else if (ThreePane_3.Checked)
            {
                dbDefine.Template = "ThreePane_3";
            }
            else if (ThreePane_4.Checked)
            {
                dbDefine.Template = "ThreePane_4";
            }
            else
            {
                // default case
                dbDefine.Template = "TwoPane_1";
            }
            // filters
            dbDefine.Filters = this.ctrl_DashboardFilters.Controls.OfType<wcInteractionFilter>()
                    .Select(p => p.Get_FilterInfo()).ToList();
            // portlets which are used
            dbDefine.UsingPortlets = m_selectedPortlets;

            lsttbl_Dashboard db = new lsttbl_Dashboard()
            {
                Code = Lib.IfNOE(MySession.DashboardDefine_CurEditing, String.Format("dbrd_{0}_{1}", WHCode, DateTime.Now.ToString("yyyyMMddHHmmss"))),
                Name = txtDashboardName.Text,
                WHCode = this.WHCode,
                JsonStr = dbDefine.ToJsonStr(),
                IsDefault = chkDefault.Checked
            };
            MyBI.Me.Save_Dashboard(db);
            // clean session data
            MySession.DashboardDefine_CurEditing = null;
            MySession.DashboardDefine_UsingPortlet.Clear();
            Response.Redirect("DashboardSetting.aspx?whcode=" + WHCode);
        }
        protected void btn_Click(object sender, EventArgs e)
        {
            try
            {
                var btn = sender as ASPxButton;
                if (btn.ID == this.btnIn.ID)
                {
                    var item = this.lbxAvailablePortlet.SelectedItem;
                    if (item == null) return;
                    var portletCode = Lib.NTE(item.Value);
                    var info = new COMCodeNameObj(portletCode, item.Text);
                    var sel_UsingPortlet = MySession.DashboardDefine_UsingPortlet;
                    if (sel_UsingPortlet.ToArray().Exists(p => p.GetStr("Code") == info.Code)) return;
                    sel_UsingPortlet.Add(info);
                    Helpers.SetDataSource(this.lbxUsingPortlet, sel_UsingPortlet, "Code", "Name");
                }
                else if (btn.ID == this.btnOut.ID)
                {
                    var itemRemove = lbxUsingPortlet.SelectedItem;
                    this.lbxUsingPortlet.Items.Remove(itemRemove);
                    var objRemove = MySession.DashboardDefine_UsingPortlet.ToArray()
                        .FirstOrDefault(p => p.GetStr("Code") == Lib.NTE(itemRemove.Value));
                    MySession.DashboardDefine_UsingPortlet.Remove(objRemove);
                }
                else if (btn.ID == this.btnView.ID)
                {

                }
                else if (btn.ID == this.btnNew.ID)
                {
                    this.Reset_Info();
                }
                else if (btn.ID == this.btnEdit.ID)
                {
                    this.Reset_Info();
                    if (this.lbxDashboard.SelectedItem == null) return;
                    var dbrdCode = Lib.NTE(this.lbxDashboard.SelectedItem.Value);
                    MySession.DashboardDefine_CurEditing = dbrdCode;
                    var obj = MyBI.Me.Get_DashboardBy(dbrdCode);
                    var objDbrd = obj.JsonObj;
                    this.txtDisplayName.Text = objDbrd.DisplayName;
                    this.cboTemplate.Value = objDbrd.Template;
                    this.chkIsDefault.Checked = obj.IsDefault;
                    var usingPortlets = objDbrd.Get_UsingPortlets();
                    MySession.DashboardDefine_UsingPortlet.AddRange(usingPortlets);
                    Helpers.SetDataSource(this.lbxUsingPortlet, usingPortlets, "Code", "Name");
                    // Add Filter.
                    foreach (var item in objDbrd.Filters)
                    {
                        var ctrl = this.Add_FilterControl(false);
                        ctrl.Set_FilterInfo(item);
                    }
                }
                else if (btn.ID == this.btnSave.ID)
                {
                    var objSett = this.Get_DefineInfo();
                    var actionName = Lib.IsNOE(MySession.DashboardDefine_CurEditing) ? "Add new " : "Update ";
                    try
                    {
                        // Gọi hàm save
                        var objDbrd = new lsttbl_Dashboard()
                        {
                            Code = Lib.IfNOE(MySession.DashboardDefine_CurEditing, string.Format("dbrd_{0}_{1}", this.WHCode, DateTime.Now.ToString("yyyyMMddHHmmss"))),
                            Name = this.txtDisplayName.Text,
                            WHCode = this.WHCode,
                            JsonStr = objSett.ToJsonStr(),
                            IsDefault = this.chkIsDefault.Checked
                        };
                        MyBI.Me.Save_Dashboard(objDbrd);
                        Helpers.SetDataSource(this.lbxDashboard, MyBI.Me.Get_Dashboard(this.WHCode).ToList(), "Code", "Name");
                        MySession.DashboardDefine_CurEditing = objDbrd.Code;
                    }
                    catch { this.Set_SaveMsgText(string.Format("{0} failed!", actionName), true); }
                    this.Set_SaveMsgText(string.Format("{0} success!", actionName), false);
                }
                else if (btn.ID == this.btnAddDashboardFilter.ID)
                    this.Add_FilterControl(false);
            }
            catch { }
        }