public static string[] GetCompletionList(string prefixText, int count, string contextKey)
    {
        DMClienCompanyMaster Obj_CCMaster = new DMClienCompanyMaster();

        String[] SearchList = Obj_CCMaster.GetSuggestedRecord(prefixText);
        return(SearchList);
    }
    protected void BtnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            int DeleteId = 0;

            if (ViewState["ITEMINUSEORNOT"] == null)
            {
                if (ViewState["EditID"] != null)
                {
                    DeleteId = Convert.ToInt32(ViewState["EditID"]);
                }
                if (DeleteId != 0)
                {
                    Entity_CCMaster.ClientCompanyId = DeleteId;
                    Entity_CCMaster.DeletedBy       = Convert.ToInt32(Session["UserID"]);
                    Entity_CCMaster.DeletedDate     = DateTime.Now;
                    Entity_CCMaster.IsDelete        = true;

                    int iDelete = Obj_CCMaster.DeleteRecord(ref Entity_CCMaster, out StrError);
                    if (iDelete > 0)
                    {
                        obj_Comman.ShowPopUpMsg("Record Deleted Successfully..!", this.Page);
                        EmptyFormFields();
                        EmptyMasterForm();
                        setInitialRow();
                        ReportGrid(StrCondition);
                    }
                    else
                    {
                        obj_Comman.ShowPopUpMsg("Item is used in Transaction, Please delete references from Transaction to perform delete operation...!", this.Page);
                    }
                }
            }
            else
            {
                obj_Comman.ShowPopUpMsg("Cant Delete Record.. \nUsed In Further Process..!", this.Page);
            }
            Entity_CCMaster = null;
            Obj_CCMaster    = null;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
    private void GETCLIENTPDF(int ClientCompantID, int CompanyID, int WITHREMARK)
    {
        try
        {
            DMClienCompanyMaster obj_Template = new DMClienCompanyMaster();
            ReportDocument       CRpt         = new ReportDocument();
            DataSet dslogin   = new DataSet();
            string  PDFMaster = string.Empty;
            string  StrError  = string.Empty;
            dslogin = obj_Template.GetCCMFORPRINT(ClientCompantID, CompanyID, out StrError);
            dslogin.Tables[0].TableName = "CLIENTCOMPAY";
            dslogin.Tables[1].TableName = "COMPANY";

            //----------------------------Image Print---------------------------------------------------------------
            string Image      = dslogin.Tables[1].Rows[0]["CLogo"].ToString();
            string ImageSign  = dslogin.Tables[1].Rows[0]["DigitalSignature"].ToString();
            string ImageSign1 = dslogin.Tables[1].Rows[0]["DigitalSignature1"].ToString();
            string ImageSign2 = dslogin.Tables[1].Rows[0]["DigitalSignature2"].ToString();
            dslogin.Tables[1].Columns.Add("CompanyLogo", System.Type.GetType("System.Byte[]"));
            dslogin.Tables[1].Columns.Add("Sign1", System.Type.GetType("System.Byte[]"));
            dslogin.Tables[1].Columns.Add("Sign2", System.Type.GetType("System.Byte[]"));
            dslogin.Tables[1].Columns.Add("Sign3", System.Type.GetType("System.Byte[]"));
            Image = Image.Replace("~", "");
            Image = Image.Replace("/", "\\");

            ImageSign = ImageSign.Replace("~", "");
            ImageSign = ImageSign.Replace("/", "\\");

            ImageSign1 = ImageSign1.Replace("~", "");
            ImageSign1 = ImageSign1.Replace("/", "\\");

            ImageSign2 = ImageSign2.Replace("~", "");
            ImageSign2 = ImageSign2.Replace("/", "\\");


            FileStream   fs;
            BinaryReader br;
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + Image))
            {
                fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + Image, FileMode.Open);

                br = new BinaryReader(fs);
                byte[] imgbyte = new byte[fs.Length + 1];
                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));

                dslogin.Tables[1].Rows[0]["CompanyLogo"] = imgbyte;
                dslogin.Tables[1].Rows[dslogin.Tables[1].Rows.Count - 1]["CompanyLogo"] = imgbyte;


                br.Close();
                fs.Close();
            }
            FileStream   fss1;
            BinaryReader brs1;

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign))
            {
                fss1 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign, FileMode.Open);

                brs1 = new BinaryReader(fss1);
                byte[] imgbyte1 = new byte[fss1.Length + 1];
                imgbyte1 = brs1.ReadBytes(Convert.ToInt32((fss1.Length)));

                dslogin.Tables[1].Rows[0]["Sign1"] = imgbyte1;
                dslogin.Tables[1].Rows[dslogin.Tables[1].Rows.Count - 1]["Sign1"] = imgbyte1;


                brs1.Close();
                fss1.Close();
            }

            FileStream   fss2;
            BinaryReader brs2;
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign1))
            {
                fss2 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign1, FileMode.Open);

                brs2 = new BinaryReader(fss2);
                byte[] imgbyte2 = new byte[fss2.Length + 1];
                imgbyte2 = brs2.ReadBytes(Convert.ToInt32((fss2.Length)));

                dslogin.Tables[1].Rows[0]["Sign2"] = imgbyte2;
                dslogin.Tables[1].Rows[dslogin.Tables[1].Rows.Count - 1]["Sign2"] = imgbyte2;


                brs2.Close();
                fss2.Close();
            }
            FileStream   fss3;
            BinaryReader brs3;
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageSign2))
            {
                fss3 = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageSign2, FileMode.Open);

                brs3 = new BinaryReader(fss3);
                byte[] imgbyte3 = new byte[fss3.Length + 1];
                imgbyte3 = brs3.ReadBytes(Convert.ToInt32((fss3.Length)));

                dslogin.Tables[1].Rows[0]["Sign3"] = imgbyte3;
                dslogin.Tables[1].Rows[dslogin.Tables[1].Rows.Count - 1]["Sign3"] = imgbyte3;


                brs3.Close();
                fss3.Close();
            }

            //-------------------------------------------------------------------------------------------
            if (WITHREMARK == 0)
            {
                CRpt.Load(Server.MapPath("~/CrystalPrint/ClientCompanyPrint.rpt"));
                CRpt.SetDataSource(dslogin);
                string DATE = DateTime.Now.ToString("dd-MMM-yyyy ss");
                PDFMaster = Server.MapPath(@"~/TempFiles/" + "ClientCompay - " + (DATE) + ".pdf");
                CRpt.ExportToDisk(ExportFormatType.PortableDocFormat, PDFMaster);
                CHKATTACHBROUCHER.Checked = true;
                CHKATTACHBROUCHER.Text    = "Contact Details";
                CHKATTACHBROUCHER.ToolTip = PDFMaster;

                iframepdf.Attributes.Add("src", "../TempFiles/" + "ClientCompay - " + (DATE) + ".pdf");
            }
            else
            {
                CRpt.Load(Server.MapPath("~/CrystalPrint/ClientCompanyPrintWithRemark.rpt"));
                CRpt.SetDataSource(dslogin);
                string DATE = DateTime.Now.ToString("dd-MMM-yyyy ss");
                PDFMaster = Server.MapPath(@"~/TempFiles/" + "ClientCompayDetails - " + (DATE) + ".pdf");
                CRpt.ExportToDisk(ExportFormatType.PortableDocFormat, PDFMaster);
                CHKATTACHBROUCHER.Checked = true;
                CHKATTACHBROUCHER.Text    = "Contact Details";
                CHKATTACHBROUCHER.ToolTip = PDFMaster;

                iframepdf.Attributes.Add("src", "../TempFiles/" + "ClientCompayDetails - " + (DATE) + ".pdf");
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        int    UpdateRow = 0, UpdateRowDtls = 0, UpdateRow1 = 0, UpdateUnitCal = 0;
        string StrError = "";

        try
        {
            if (ViewState["EditID"] != null)
            {
                Entity_CCMaster.ClientCompanyId = Convert.ToInt32(ViewState["EditID"]);
            }
            Entity_CCMaster.CompanyName = TxtCompanyName.Text;
            Entity_CCMaster.SupplierFor = TxtSupplierFor.Text;
            Entity_CCMaster.Address     = TxtAddress.Text;
            Entity_CCMaster.WebUrl      = TxtWebsite.Text;
            Entity_CCMaster.Remark      = TxtRemark.Text;


            Entity_CCMaster.UpdatedBy   = Convert.ToInt32(Session["UserId"]);
            Entity_CCMaster.UpdatedDate = DateTime.Now;

            UpdateRow = Obj_CCMaster.UpdateRecord(ref Entity_CCMaster, out StrError);

            if (UpdateRow > 0)
            {
                if (ViewState["CurrentTable"] != null)
                {
                    DataTable dtInsert = new DataTable();
                    dtInsert = (DataTable)ViewState["CurrentTable"];
                    for (int i = 0; i < dtInsert.Rows.Count; i++)
                    {
                        //Entity_CCMaster.PersonId = Convert.ToInt32(dtInsert.Rows[i]["#"].ToString());
                        Entity_CCMaster.ClientCompanyId = Convert.ToInt32(ViewState["EditID"]);
                        Entity_CCMaster.PersonName      = dtInsert.Rows[i]["PersonName"].ToString();
                        Entity_CCMaster.Designation     = dtInsert.Rows[i]["Designation"].ToString();
                        Entity_CCMaster.ContactNo1      = dtInsert.Rows[i]["ContactNo1"].ToString();
                        Entity_CCMaster.ContactNo2      = dtInsert.Rows[i]["ContactNo2"].ToString();
                        Entity_CCMaster.EmailId1        = dtInsert.Rows[i]["EmailId1"].ToString();
                        Entity_CCMaster.EmailId2        = dtInsert.Rows[i]["EmailId2"].ToString();
                        Entity_CCMaster.Note            = dtInsert.Rows[i]["Note"].ToString();
                        UpdateRowDtls = Obj_CCMaster.InsertDertailsRecord(ref Entity_CCMaster, StrError);
                    }
                }

                //if (ViewState["CurrentTableSize"] != null)
                //{
                //    DataTable dtInsert = new DataTable();
                //    dtInsert = (DataTable)ViewState["CurrentTableSize"];
                //    for (int i = 0; i < dtInsert.Rows.Count; i++)
                //    {
                //        //Entity_ItemMaster.ItemId = Convert.ToInt32(ViewState["EditID"]);
                //        //Entity_ItemMaster.SupplierId = Convert.ToInt32(dtInsert.Rows[i]["SizeId"].ToString());
                //        //UpdateRowDtls = Obj_ItemMaster.InsertDetailsSizeRecord(ref Entity_ItemMaster, out StrError);
                //    }
                //}
            }
            if (UpdateRow > 0)
            {
                obj_Comman.ShowPopUpMsg("Record Updated Successfully", this.Page);
                EmptyFormFields();
                EmptyMasterForm();
                setInitialRow();
                ReportGrid(StrCondition);
                Entity_CCMaster = null;
                Obj_CCMaster    = null;
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }