private void AddItem_Load(object sender, EventArgs e)
        {
            DosageForm doFrm = new DosageForm();
            doFrm.GetDosageForItem();

            doFrm.Sort = "Form";
            cboDosageForm.DataSource = doFrm.DefaultView;

            Unit un = new Unit();
            un.LoadAll();
            un.Sort = "Unit";
            cboUnit.DataSource = un.DefaultView;

            Product pInn = new Product();
            pInn.GetInnForItem();

            pInn.Sort = "IIN";
            cboIIN.DataSource = pInn.DefaultView;

            if (_categoryId != 0)
            {
                SubCategory cat = new SubCategory();
                DataTable dtProd = cat.GetSubCategoryByID(_categoryId);
                string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                ListViewItem listCat = new ListViewItem(categor) {Tag = dtProd.Rows[0]["ID"]};
                lstCat.Items.Add(listCat);
                //txtCatCode.Text = dtProd.Rows[0]["CategoryCode"].ToString() + "-" + dtProd.Rows[0]["SubCategoryCode"].ToString();
            }
            else
            {
                PopulateFields();
            }
        }
Esempio n. 2
0
 protected void uiRepeaterCats_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         DataRowView row = (DataRowView)e.Item.DataItem;
         SubCategory subs = new SubCategory();
         subs.GetSubCategoryByCategoryID(Convert.ToInt32(row["CategoryID"].ToString()));
         if (subs.RowCount > 0)
         {
             Repeater subrep = (Repeater)e.Item.FindControl("uiRepeaterSubcats");
             subrep.DataSource = subs.DefaultView;
             subrep.DataBind();
         }
     }
 }
        private void PopulateCatTree()
        {
            ProductTree.Nodes.Clear();
            if (Convert.ToInt32(lkCommodityTypes.EditValue) == BLL.Type.Constants.Pharmacuticals)
            {
                Category cat = new Category();
                SubCategory subCat = new SubCategory();
                Product prod = new Product();
                cat.LoadAll();
                cat.Sort = "CategoryName";
                ProductTree.Nodes.Add("All0", "All");
                foreach (DataRowView dv in cat.DefaultView)
                {
                    TreeNode nodes = new TreeNode();
                    nodes.Name = "cat" + dv["ID"].ToString();
                    nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")";
                    nodes.ToolTipText = "Double Click to List";
                    subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                    subCat.Sort = "SubCategoryName";
                    foreach (DataRowView subDv in subCat.DefaultView)
                    {

                        TreeNode subNodes = new TreeNode();
                        subNodes.Name = "sub" + subDv["ID"].ToString();
                        subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")";
                        subNodes.ToolTipText = "Double Click to List";

                        nodes.Nodes.Add(subNodes);
                    }
                    ProductTree.Nodes[0].Nodes.Add(nodes);

                }
                ProductTree.Nodes[0].Expand();
            }
            else
            {
                SupplyCategory scat = new SupplyCategory();
                scat.LoadAll();
                scat.Sort = "Name";
                ProductTree.Nodes.Add("Als0", "All");
                foreach (DataRowView dv in scat.DefaultView)
                {
                    TreeNode nodes = new TreeNode();
                    nodes.Name = "sup" + dv["ID"].ToString();
                    nodes.Text = dv["Name"].ToString();
                    nodes.ToolTipText = "Double Click to List";
                    ProductTree.Nodes[0].Nodes.Add(nodes);

                }
                ProductTree.Nodes[0].Expand();
            }
        }
        /// <summary>
        /// Handles the treeCategory focused node changed and updates the form accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            if (treeCategory.Selection.Count == 0)
                return;

            string value = treeCategory.Selection[0].GetValue("ID").ToString();
            int categoryId = Convert.ToInt32(value.Substring(1));
            string type = "cat";
            if (value.Substring(0, 1) == "S")
            {
                type = "sub";
            }
            else if (value == "P999")
            {
                type = "All";
            }

            if (type == "cat")
            {
                cat.LoadByPrimaryKey(categoryId);
                cboCategory.SelectedValue = categoryId.ToString();
                cboCategory.Visible = false;
                txtCategory.Text = cat.CategoryName;
                txtCatCode.Text = cat.CategoryCode;
                txtDescription.Text = cat.Description;
                _catId = cat.ID;

            }
            else if (type == "sub")
            {
                subCat.LoadByPrimaryKey(categoryId);
                cboCategory.Visible = true;

                cboCategory.SelectedValue = subCat.CategoryId.ToString();
                txtCategory.Text = subCat.SubCategoryName;
                txtCatCode.Text = subCat.SubCategoryCode;
                txtDescription.Text = subCat.Description;
                _catId = subCat.ID;
            }
            btnSave.Text = "Update";
        }
        /// <summary>
        /// Saves Category/Sub Category related information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtCategory.Text != "" || txtCatCode.Text != "")
            {
                if (cboCategory.Visible)
                {
                    SubCategory subCat = new SubCategory();
                    if (_catId != 0)
                        subCat.LoadByPrimaryKey(_catId);
                    else
                        subCat.AddNew();

                    subCat.CategoryId = Convert.ToInt32(cboCategory.SelectedValue);
                    subCat.SubCategoryName = txtCategory.Text;
                    subCat.Description = txtDescription.Text;
                    subCat.SubCategoryCode = txtCatCode.Text;
                    subCat.Save();
                }
                else
                {
                    Category cat = new Category();
                    if (_catId != 0)
                        cat.LoadByPrimaryKey(_catId);
                    else
                        cat.AddNew();
                    cat.CategoryName = txtCategory.Text;
                    cat.Description = txtDescription.Text;
                    cat.CategoryCode = txtCatCode.Text;
                    cat.Save();
                }

                PopulateCategoryTree();
                ResetCategoryForm();
            }
            else
            {
                if (txtCatCode.Text == "")
                    txtCatCode.BackColor = Color.FromArgb(251, 214, 214);
                if (txtCategory.Text == "")
                    txtCategory.BackColor = Color.FromArgb(251, 214, 214);
            }
        }
Esempio n. 6
0
        public static Helper.ChatRoom GetRoomInfo(int id, bool isTemp, Room room)
        {
            Helper.ChatRoom roomObject = new Helper.ChatRoom();
            roomObject.ID = id;
            roomObject.Type = "Room";
            roomObject.IsTemp = isTemp;
            roomObject.Message = "";
            roomObject.AdminMessage = "";

            //Room info
            roomObject.Name = room.Name;
            roomObject.RoomTopic = room.RoomTopic;
            roomObject.fbURL = room.FbURL;
            roomObject.tURL = room.TURL;
            roomObject.utURL = room.UtURL;
            roomObject.OpenCams = room.OpenCams;
            if (!room.IsColumnNull("CreatedBy"))
                roomObject.CreatedBy = room.CreatedBy;

            RoomBot Allbots = new RoomBot();
            roomObject.RoomBots = Allbots.GetByRoomID(id);

            if (!room.IsColumnNull("CreatedDate"))
                roomObject.CreatedDate = room.CreatedDate;

            //Room settings
            roomObject.Settings.EnableCam = room.EnableCam;
            roomObject.Settings.EnableMic = room.EnableMic;
            roomObject.Settings.MarkOnLoginWithoutWrite = room.MarkOnLoginWithoutWrite;
            roomObject.Settings.MarkOnLoginWithWrite = room.MarkOnLoginWithWrite;
            roomObject.Settings.EnableMicForAdminsOnly = room.EnableMicForAdminsOnly;
            if (room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID > 1) // not a free room
                roomObject.Settings.CamCount = 8;
            else
                roomObject.Settings.CamCount = 4;
            roomObject.Settings.MaxMic = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.MicCount;
            roomObject.Settings.TypeID = room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID;
            roomObject.Settings.Color = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Color;
            //Room Members
            RoomMember roomMember = new RoomMember();
            if (!roomMember.LoadByPrimaryKey(BLL.Member.CurrentMember.MemberID, id))
            {
                roomMember.AddNew();
                roomMember.MemberID = BLL.Member.CurrentMember.MemberID;
                roomMember.RoomID = id;
            }
            roomMember.InRoom = true;
            roomMember.LastJoinDate = DateTime.Now;
            if (BLL.Member.CurrentMember.Status == (int)Helper.Enums.MemberStatus.Offline && Helper.Admin.HasRole(Helper.Enums.MemberRoles.InvisibleInRoom.ToString()))
                roomMember.InRoom = false;
            if (!room.IsColumnNull("CreatedBy"))
            {
                if (roomMember.MemberID == room.CreatedBy)
                    roomMember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner;
            }
            roomMember.Save();
            roomObject.CurrentMemberID = BLL.Member.CurrentMemberID;

            List<int> connectedIDs = ChatRoomHub.ConnectedUsers.Select(m => m.MemberID).ToList();
            roomObject.Members = roomMember.LoadWithSettings(id, roomObject.CurrentMemberID, null, connectedIDs);
            var currentMemberSettings = roomObject.Members.First(m => m.MemberID == roomObject.CurrentMemberID);
            if (currentMemberSettings != null)
            {
                if (room.MarkOnLoginWithWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = true;
                }
                if (room.MarkOnLoginWithoutWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = false;
                }
            }
            // load owner / admins
            //roomObject.Admins = roomMember.GetAdminsMembersByRoomID(id);

            // load cat & subcat

            Category cat = new Category();
            if (!room.IsColumnNull("CategoryID"))
            {
                cat.LoadByPrimaryKey(room.CategoryID);
                roomObject.CategoryName = cat.Name;
            }

            SubCategory scat = new SubCategory();
            if (!room.IsColumnNull("SubCategoryID"))
            {
                scat.LoadByPrimaryKey(room.SubCategoryID);
                roomObject.SubCategoryName = scat.Name;
            }
            else
            {
                roomObject.SubCategoryName = "لا يوجد";
            }

            //member level change
            roomObject.MemberLevels = Helper.EnumUtil.GetValues<Helper.Enums.RoomMemberLevel>().Where(l => (int)l < currentMemberSettings.MemberLevelID).Select(l => new
            {
                ID = (int)l,
                Name = Helper.StringEnum.GetStringValue(l)
            }).ToList();

            //messages
            //roomObject.MessageHistory = new RoomMessages().GetLatestMessags(id, 0);
            roomObject.MessageHistory = new List<Helper.ChatMessage>() { };
            ///////////////////////////

            Gift allgifts = new Gift();
            allgifts.LoadAll();
            roomObject.Gifts = allgifts.DefaultView.Table.AsEnumerable().Select(m => new { giftid = m["GiftID"], name = m["Name"], price = m["Price_Point"], picPath = m["PicPath"], AudioPath = m["AudioPath"] }).ToList();

            //bots
            RoomBot bllRoomBot = new BLL.RoomBot();
            //welcome bot
            List<Info.RoomBot> bots = bllRoomBot.GetByRoomIDandBotID(id, Helper.Enums.Bot.Welcome);
            if (bots.Count > 0)
            {
                Info.WelcomeBot infoWelcomeBot = (Info.WelcomeBot)bots.First().Settings;
                roomObject.WelcomeBot = infoWelcomeBot;
            }

            return roomObject;
        }
        private void ManageItems_Load(object sender, EventArgs e)
        {
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            Product prod = new Product();
            cat.LoadAll();
            cat.Sort = "CategoryName";
            lblCategory.Text = "Products By Category";
            ProductTree.Nodes.Add("All0","All");
            foreach (DataRowView dv in cat.DefaultView)
            {
                TreeNode nodes = new TreeNode();
                nodes.Name =  "cat" + dv["ID"].ToString();
                nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")";
                nodes.ToolTipText = "Double Click to List";
                subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                subCat.Sort = "SubCategoryName";
                foreach (DataRowView subDv in subCat.DefaultView)
                {

                    TreeNode subNodes = new TreeNode();
                    subNodes.Name = "sub" + subDv["ID"].ToString();
                    subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")";
                    subNodes.ToolTipText = "Double Click to List";

                    nodes.Nodes.Add(subNodes);
                }
               ProductTree.Nodes[0].Nodes.Add(nodes);

            }
            ProductTree.Nodes[0].Expand();

            Stores stor = new Stores();
            stor.GetActiveStores();
            cboStores.DataSource = stor.DefaultView;
        }
Esempio n. 8
0
 private void BindSubCatsForEdit()
 {
     SubCategory subcats = new SubCategory();
     if (uiDropDownListEdit_Category.SelectedIndex != -1)
         subcats.GetSubCategoryByCategoryID(Convert.ToInt32(uiDropDownListEdit_Category.SelectedValue));
     uiDropDownListEditSubCat.DataSource = subcats.DefaultView;
     uiDropDownListEditSubCat.DataTextField = "Name";
     uiDropDownListEditSubCat.DataValueField = "SubCategoryID";
     uiDropDownListEditSubCat.DataBind();
     uiDropDownListEditSubCat.Items.Insert(0, new ListItem("إختر قسم فرعى. . . ."));
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Items itm = new Items();
            if (_itemId != 0)
                itm.LoadByPrimaryKey(_itemId);
            else
            {
                itm.AddNew();
                itm.IsInHospitalList = true;

                Items itms = new Items();
                itm.ID = itms.GetNextItemID();
                itm.StorageTypeID = 1;
                itm.NearExpiryTrigger = 0;
            }
            itm.IINID = Convert.ToInt32(cboIIN.SelectedValue);

            //itm.StockCode = txtCatCode.Text + "-" + txtStockCode.Text;
            itm.StockCode = txtStockCode.Text;
            itm.Code = txtStock2.Text;
            itm.StockCodeDACA = txtStock3.Text;
            itm.Strength = txtStrength.Text;
            itm.DosageFormID = Convert.ToInt32(cboDosageForm.SelectedValue);
            itm.IsDiscontinued = ckIsDiscontinued.Checked;
            itm.IsFree = ckIsFree.Checked;
            itm.EDL = ckIsEDL.Checked;
            itm.UnitID = Convert.ToInt32(cboUnit.SelectedValue);
            itm.Pediatric = ckIsPedatric.Checked;
            itm.Refrigeratored = ckIsRefrigerated.Checked;
            itm.NeedExpiryBatch = true;
            itm.Save();

            ProductsCategory prodCate = new ProductsCategory();
            foreach (ListViewItem lstC in lstCat.Items)
            {
                int catId = Convert.ToInt32(lstC.Tag);

                if (prodCate.CategoryExists(itm.ID, catId)) continue;

                prodCate.AddNew();
                prodCate.ItemId = itm.ID;
                prodCate.SubCategoryID = catId;
                prodCate.Save();
            }

            if (itm.IsColumnNull("StockCode"))
            {
                // Update the Stock Code

                prodCate.Rewind();
                SubCategory sc = new SubCategory();
                sc.LoadByPrimaryKey(prodCate.SubCategoryID);

                if(sc.RowCount > 0)
                {
                    itm.StockCode = string.Format("{0}.{1}.{2}.{3}",sc.SubCategoryCode, 1, itm.DosageFormID, 1);
                    itm.Save();
                }
            }
            XtraMessageBox.Show( "Item is Saved Successfully!" , "Confirmation" , MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Close();
        }
        private void ProductTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                Items itm = new Items();
                DataTable dtItem = new DataTable();
                string value = ProductTree.SelectedNode.Name;
                string type = value.Substring(0, 3);
                int len = value.Length - 3;
                int categoryId = Convert.ToInt32(value.Substring(3, len));

                if (type == "sub")
                {
                    SubCategory cat = new SubCategory();
                    DataTable dtProd = cat.GetSubCategoryByID(categoryId);
                    string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                    ListViewItem listCat = new ListViewItem(categor);
                    listCat.Tag = dtProd.Rows[0]["ID"];
                    lstCat.Items.Add(listCat);
                    ProductTree.Visible = false;
                }
            }
            catch
            { }
        }
        private void PopulateFields()
        {
            try
            {
                if (_itemId == 0) return;

                Items itm = new Items();

                itm.LoadByPrimaryKey(_itemId);
                SubCategory cat = new SubCategory();
                DataTable dtCat = cat.GetSubCategoryOfItem(_itemId);
                foreach (DataRow drcat in dtCat.Rows)
                {
                    DataTable dtProd = cat.GetSubCategoryByID(Convert.ToInt32(drcat["SubCategoryID"]));
                    //txtCategory.Text = dtProd.Rows[0]["CategoryName"].ToString();
                    //txtSubCategory.Text = dtProd.Rows[0]["SubCategoryName"].ToString();
                    string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() };
                    ListViewItem listCat = new ListViewItem(categor) { Tag = dtProd.Rows[0]["ID"] };
                    lstCat.Items.Add(listCat);
                }
                cboIIN.SelectedValue = itm.IINID.ToString();
                Product nInn = new Product();
                nInn.LoadByPrimaryKey(itm.IINID);
                //txtATC.Text = nInn.ATC;
                txtStrength.Text = itm.Strength;
                ckIsDiscontinued.Checked = itm.IsDiscontinued;
                ckIsEDL.Checked = itm.EDL;
                ckIsFree.Checked = itm.IsFree;
                ckIsPedatric.Checked = itm.Pediatric;
                ckIsRefrigerated.Checked = itm.Refrigeratored;
                cboDosageForm.SelectedValue = itm.DosageFormID.ToString();
                cboUnit.SelectedValue = itm.UnitID.ToString();
                string code = itm.StockCode;
                txtStockCode.Text = code;
                txtStock2.Text = itm.Code;
                txtStock3.Text = itm.StockCodeDACA;
            }
            catch
            {

            }
        }
        private void PopulateCategory()
        {
            ProductTree.Nodes.Clear();
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            cat.LoadAll();
            cat.Sort = "CategoryName";
            ProductTree.Nodes.Add("All0", "All");
            foreach (DataRowView dv in cat.DefaultView)
            {
                TreeNode nodes = new TreeNode
                                     {
                                         Name = "cat" + dv["ID"].ToString(),
                                         Text =
                                             dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")",
                                         ToolTipText = "Double click to add"
                                     };
                subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                subCat.Sort = "SubCategoryName";
                foreach (DataRowView subDv in subCat.DefaultView)
                {
                    if (!ExistInList(Convert.ToInt32(subDv["ID"])))
                    {
                        TreeNode subNodes = new TreeNode
                                                {
                                                    Name = "sub" + subDv["ID"].ToString(),
                                                    Text =
                                                        subDv["SubCategoryName"].ToString() + " (" +
                                                        subDv["SubCategoryCode"].ToString() + ")",
                                                    ToolTipText = "Double click to add"
                                                };

                        nodes.Nodes.Add(subNodes);
                    }
                }
                ProductTree.Nodes[0].Nodes.Add(nodes);
            }
            ProductTree.Nodes[0].Expand();
        }