Exemplo n.º 1
0
        public void Update()
        {
            txtRate.Text = "0";
            FollowUPMaster FollowUP = new FollowUPMaster();

            FollowUP.Description      = Convert.ToString(txtDescription.Text);
            FollowUP.Rate             = Convert.ToDouble(txtRate.Text);
            FollowUP.DepartmentId     = cmbDeparment.SelectedValue.ToString();
            FollowUP.FollowUpItemName = txtName.Text;
            var subItems = listOfSubItem.Items;

            FollowUP.ID       = Convert.ToInt16(txtID.Text);
            FollowUP.SubItems = new List <FollowUpSubItem>();

            for (int i = 0; i < subItems.Count; i++)
            {
                FollowUpSubItem item = new FollowUpSubItem();
                item.ItemId      = Convert.ToInt32(txtID.Text); item.Id = subItems[i].SubItems[1].Text;
                item.SubItemName = subItems[i].SubItems[2].Text;
                FollowUP.SubItems.Add(item);
            }

            MessageModel messageModel = new FollowUpManager().UpdateService(FollowUP);

            MessageBox.Show(messageModel.MessageBody, messageModel.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            SetNew();
        }
Exemplo n.º 2
0
        public int UpdateService(FollowUPMaster followUp)
        {
            int count = 0;

            Command = new SqlCommand("Update dbo.tblFollowUp set FollowUpItemName=@FollowUpItemName,Description=@Description,DepartmentID=@DepartmentID,Rate=@Rate where ID='" + followUp.ID + "'", Connection);

            Command.CommandType = CommandType.Text;
            Command.Parameters.AddWithValue("@FollowUpItemName", followUp.FollowUpItemName);
            Command.Parameters.AddWithValue("@Description", followUp.Description);
            Command.Parameters.AddWithValue("@DepartmentID", "");
            Command.Parameters.AddWithValue("@Rate", followUp.Rate);
            count = Command.ExecuteNonQuery();

            Command             = new SqlCommand("Delete tblFollowSubItems where  ItemID ='" + followUp.ID + "'", Connection);
            Command.CommandType = CommandType.Text;
            count = Command.ExecuteNonQuery();
            foreach (FollowUpSubItem subItem in followUp.SubItems)
            {
                Command = new SqlCommand("INSERT INTO dbo.tblFollowSubItems (ItemID,SubItemName,Id)"
                                         + "VALUES(@ItemID,@SubItemName,@Id)", Connection);

                Command.CommandType = CommandType.Text;
                Command.Parameters.AddWithValue("@ItemID", followUp.ID);
                Command.Parameters.AddWithValue("@SubItemName", subItem.SubItemName);
                Command.Parameters.AddWithValue("@Id", subItem.Id);
                count = Command.ExecuteNonQuery();
            }
            return(count);
        }
Exemplo n.º 3
0
        public int SaveFollowUPSetup(FollowUPMaster followUp)
        {
            int count = 0;

            Command = new SqlCommand("INSERT INTO dbo.tblFollowUp (FollowUpItemName,Description,DepartmentID,Rate, ID)"
                                     + "VALUES(@FollowUpItemName,@Description,@DepartmentID,@Rate,@ID)", Connection);

            Command.CommandType = CommandType.Text;
            Command.Parameters.AddWithValue("@FollowUpItemName", followUp.FollowUpItemName);
            Command.Parameters.AddWithValue("@Description", followUp.Description);
            Command.Parameters.AddWithValue("@DepartmentID", "");
            Command.Parameters.AddWithValue("@Rate", followUp.Rate);
            Command.Parameters.AddWithValue("@ID", followUp.ID);


            count = Command.ExecuteNonQuery();

            foreach (FollowUpSubItem subItem in followUp.SubItems)
            {
                Command = new SqlCommand("INSERT INTO dbo.tblFollowSubItems (ItemID,SubItemName,Id)"
                                         + "VALUES(@ItemID,@SubItemName, @Id)", Connection);

                Command.CommandType = CommandType.Text;
                Command.Parameters.AddWithValue("@ItemID", followUp.ID);
                Command.Parameters.AddWithValue("@SubItemName", subItem.SubItemName);
                Command.Parameters.AddWithValue("@Id", subItem.Id);
                count = Command.ExecuteNonQuery();
            }



            return(count);
        }
Exemplo n.º 4
0
        public MessageModel UpdateService(FollowUPMaster FollowUP)
        {
            int saveService = new FollowUPGateway().UpdateService(FollowUP);

            if (saveService > 0)
            {
                messageModel.MessageBody  = "FollowUP Item Update successfully!";
                messageModel.MessageTitle = "Successfull";
            }
            return(messageModel);
        }
Exemplo n.º 5
0
        public List <FollowUPMaster> GetALLFollowUpWithSubItemsByDepartment(string Department, string Master)
        {
            List <FollowUPMaster> ListOfList = new List <FollowUPMaster>();
            DataTable             master     = new FollowUPGateway().LoadDepartmetnwiseFollowUp(Department);

            try
            {
                //.AsEnumerable().Where(a => Convert.ToInt16(a["ItemID"]) != 0).CopyToDataTable();
                foreach (DataRow dataRow in master.Rows)
                {
                    DataTable      detials  = new FollowUPGateway().LoadDepartmetnwiseSubFollowUp(Department, dataRow["ItemID"].ToString());
                    FollowUPMaster followup = new FollowUPMaster();
                    followup.SubItems = new List <FollowUpSubItem>();
                    var id = dataRow["ItemID"];
                    followup.ID = Convert.ToInt16(id);
                    followup.FollowUpItemName = dataRow["FollowUpItemName"].ToString();
                    //followup.DepartmentName = dataRow["DepartmentName"].ToString();

                    foreach (DataRow row in detials.Rows)
                    {
                        if (Convert.ToInt16(row["ItemID"]) == followup.ID)
                        {
                            followup.SubItems.Add(new FollowUpSubItem()
                            {
                                ItemId      = followup.ID,
                                Id          = row["SubId"].ToString(),
                                SubItemName = row["SubItemName"].ToString()
                            });
                        }
                    }

                    ListOfList.Add(followup);
                }
            }
            catch (Exception ex)
            {
                string messag = ex.Message;
            }


            return(ListOfList.ToList());
        }
Exemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <FollowUPMaster> List = new List <FollowUPMaster>();

            foreach (int row in gridView1.GetSelectedRows())
            {
                FollowUPMaster master = new FollowUPMaster();
                master.SubItems = new List <FollowUpSubItem>();
                var followupItem = gridView1.GetRowCellValue(row, "ID");
                master.ID           = Convert.ToInt16(followupItem.ToString());
                master.DepartmentId = cmbDept.SelectedValue.ToString();
                bool wasExpanded = gridView1.GetMasterRowExpanded(row);
                if (!wasExpanded)
                {
                    gridView1.ExpandMasterRow(row);
                }
                GridView detail = gridView1.GetDetailView(row, 0) as GridView;
                if (detail != null)
                {
                    foreach (int child in detail.GetSelectedRows())
                    {
                        var subItem = detail.GetRowCellValue(child, "Id");
                        master.SubItems.Add(new FollowUpSubItem
                        {
                            ItemId = Convert.ToInt16(followupItem),
                            Id     = subItem.ToString()
                        });
                    }
                }

                List.Add(master);
            }

            string msage = new FollowUpManager().SaveFollowUpSheet(List);

            MessageBox.Show(msage);
        }