public clsTransferCNIC GetTransferCNIC(int TransferID)
        {
            clsTransferCNIC image = new clsTransferCNIC();

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand("TMR_USP_GetTransferCNIC"))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Connection  = conn;
                        //conn.Open();
                        cmd.Parameters.AddWithValue("@TransferID", TransferID);

                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            image.ImageId = reader["PictureID"].ToString();
                            image.Image   = (byte[])reader["Picture"];
                        }
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                return(image = null);
            }
            return(image);
        }
        public bool AddTransferCNIC(clsTransferCNIC info)
        {
            int st = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_AddTransferCNIC"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@TransferID", info.TransferID);
                            cmd.Parameters.AddWithValue("@RegistrationNo", info.RegistrationNo);
                            cmd.Parameters.AddWithValue("@ClientID", info.ClientID);
                            cmd.Parameters.AddWithValue("@ImageId", info.ImageId);
                            cmd.Parameters.AddWithValue("@Image", info.Image);
                            st = cmd.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        private void SaveTransfer(ApprovalStatus approvalStatus)
        {
            if (EntryApproved != ApprovalStatus.Pending)
            {
                MessageBox.Show("This entry has already been Approved/Rejected");
                return;
            }

            if (id == 0 && approvalStatus != ApprovalStatus.Pending)
            {
                MessageBox.Show("This entry needs to be saved first before approval process.");
                return;
            }
            bool result;

            var info1 = new clsTransferHistory();

            info1.intID                  = this.id;
            info1.strRegistrationNo      = txtRegistration.Text.Trim();
            info1.strTransferFromID      = txtClientID.Text;
            info1.strTransferToID        = txtTransferID.Text;
            info1.dtTransferDate         = dtptransferDate.Value;
            info1.strName                = txtTransferName.Text;
            info1.strFatherOrHusbandType = cmbTransferFatherHusband.Text;
            info1.strFatherOrHusband     = txtTransferFatherHusband.Text;
            info1.strNIDOrCNIC           = txtNIDCNIC.Text;
            info1.strNationality         = cmbTransferNationality.Text;
            info1.dtDOB                  = dTPTransferDOB.Value;
            info1.strCurrentAddress1     = txtTransferCurrentAddress1.Text.Trim();
            info1.strCurrentAddress2     = txtTransferCurrentAddress2.Text.Trim();
            info1.strCurrentAddress3     = txtTransferCurrentAddress3.Text.Trim();
            info1.strCountry             = cmbTransferCountry.Text;
            info1.strCity                = txtTransferCity.Text;
            info1.strPhOff               = txtTransferPh.Text;
            info1.strRes                 = txtTransferRes.Text;
            info1.strMob                 = txtTransferMob.Text;
            info1.strFax                 = "";
            info1.strEmailAddress        = txtTransferEmailAddress.Text;


            /////////////


            if (id == 0)
            {
                info1.CreatedBy          = Dynamics.Globals.UserId;
                info1.CreationDate       = DateTime.Now;
                info1.ApprovalStatusCode = (int)ApprovalStatus.Pending;
                info1.LastUpdateDate     = new DateTime(1900, 1, 1);
                info1.LastUpdateUser     = "";
                info1.ApprovalActionUser = "";
                info1.ApprovalActionDate = new DateTime(1900, 1, 1);

                info1.intPreviousStatusCode = infoMember.intStatusCode;
            }
            else if (id != 0)
            {
                info1.CreatedBy    = Dynamics.Globals.UserId;
                info1.CreationDate = DateTime.Now;

                info1.LastUpdateDate = DateTime.Now;
                info1.LastUpdateUser = Dynamics.Globals.UserId;

                info1.ApprovalStatusCode = (int)approvalStatus;

                if (approvalStatus != ApprovalStatus.Pending)
                {
                    info1.ApprovalActionUser = Dynamics.Globals.UserId;
                    info1.ApprovalActionDate = DateTime.Now;
                }
                else
                {
                    info1.ApprovalActionUser = "";
                    info1.ApprovalActionDate = new DateTime(1900, 1, 1);
                }
            }



            int intTransID = 0;

            result = da.AddTransferHistory(info1, ref intTransID);

            if (result == false)
            {
                MessageBox.Show("An Error Occoured");
                return;
            }

            infoMember.RegistrationNo = txtRegistration.Text;
            infoMember.ClientID       = txtClientID.Text;


            infoMember.ClientID = txtTransferID.Text;

            infoMember.RegistrationNo = txtRegistration.Text.Trim();
            infoMember.ClientID       = txtTransferID.Text;

            infoMember.Name = txtTransferName.Text;
            infoMember.FatherOrHusbandType = cmbTransferFatherHusband.Text;
            infoMember.FatherOrHusband     = txtTransferFatherHusband.Text;
            infoMember.NIDOrCNIC           = txtNIDCNIC.Text;
            infoMember.Nationality         = cmbTransferNationality.Text;
            infoMember.DOB             = dTPTransferDOB.Value;
            infoMember.CurrentAddress1 = txtTransferCurrentAddress1.Text.Trim();
            infoMember.CurrentAddress2 = txtTransferCurrentAddress2.Text.Trim();
            infoMember.CurrentAddress3 = txtTransferCurrentAddress3.Text.Trim();
            infoMember.Country         = cmbTransferCountry.Text;
            infoMember.City            = txtTransferCity.Text;
            infoMember.PhOff           = txtTransferPh.Text;
            infoMember.Res             = txtTransferRes.Text;
            infoMember.Mob             = txtTransferMob.Text;
            infoMember.Fax             = "";
            infoMember.EmailAddress    = txtTransferEmailAddress.Text;


            if (approvalStatus == ApprovalStatus.Approved)
            {
                infoMember.intStatusCode = (int)memberLookupCodes.Transferred;
            }
            else if (approvalStatus == ApprovalStatus.Pending)
            {
                infoMember.intStatusCode = (int)memberLookupCodes.MarkedForTransfer;
            }
            result = da.UpdateRegistrationonTransfer(infoMember, txtClientID.Text);
            if (result == false)
            {
                MessageBox.Show("An Error Occured");
                return;
            }

            if ((approvalStatus == ApprovalStatus.Pending))
            {
                if (pbTransferToImage.Image == null)
                {
                    return;
                }
                clsTransferImage memberImage = new clsTransferImage()
                {
                    TransferID     = intTransID,
                    ClientID       = txtTransferID.Text,
                    ImageId        = txtPictureName.Text,
                    RegistrationNo = txtRegistration.Text
                };
                memberImage.Image = imageToByteArray(this.pbTransferToImage.Image);

                da.AddTransferImage(memberImage);

                if (pbTransferToCNIC.Image == null)
                {
                    return;
                }
                clsTransferCNIC memberCNIC = new clsTransferCNIC()
                {
                    TransferID     = intTransID,
                    ClientID       = txtTransferID.Text,
                    ImageId        = txtCNICName.Text,
                    RegistrationNo = txtRegistration.Text
                };
                memberCNIC.Image = imageToByteArray(this.pbTransferToCNIC.Image);

                da.AddTransferCNIC(memberCNIC);
            }
            else if ((approvalStatus == ApprovalStatus.Approved))
            {
                da.AddMemberImageonTransfer(intTransID);
                da.AddMemberCNIConTransfer(intTransID);
            }


            Clear();
        }