Example #1
0
        protected void btnStock_Click(object sender, EventArgs e)
        {

            UA = (ClinicDAL.UserAuthendication)Session[Const.LoginSession];
            
            // CHECKING MEDICINE ALREADY EXITS condition...


            string Name = Request.Form["txtSearch"];


            if (Name != "")
            {
                DataTable dt = stok.GetMedcineDetails(Name);


                if (dt.Rows.Count == 0)
                {
                    stok.ClinicID = UA.ClinicID.ToString();
                    stok.CategoryID = ddlCategory.SelectedValue;
                    stok.Name = Name;
                    stok.Qty = 0;
                    stok.Unit = txtUnit.Text;
                    stok.CreatedBy = UA.userName;
                    stok.ReOrderQty = 10;
                    stok.MedCode ="med";

                    //calling medicine insertion

                    stok.InsertMedicines();

                    HiddenFieldMedicineID.Value = stok.MedicineID.ToString();


                }
            }
           
             
                 


            //Receipt Header
            rpt.RefNo1 = txtReference1.Text;
            rpt.RefNo2 = txtReference2.Text;
            rpt.Date = Convert.ToDateTime(txtDate.Text);
            rpt.ClinicID = UA.ClinicID.ToString();
            rpt.CreatedBy = UA.userName;
            //rpt.InsertReceiptHeader();

            //Receipt Details MUST BE IN LOOP

            ReceiptDetails rptdt = new ReceiptDetails();
            rptdt.QTY = Convert.ToInt32(txtQty.Text);
            rptdt.Unit =txtUnit.Text;
        
            rptdt.MedicineID = HiddenFieldMedicineID.Value;
            rptdt.ClinicID = UA.ClinicID.ToString();
          
            rptdt.CreatedBy =UA.userName;

            //Calling insert functions
           



            //passing foreign key value 
            rptdt.ReceiptID = rpt.ReceiptID;


            rptdt.InsertReceiptDetails();


        }
        protected void btnReceipt_Click(object sender, EventArgs e)
        {
            UA = (ClinicDAL.UserAuthendication)Session[Const.LoginSession];

            rpt.CreatedBy = UA.userName;
            rpt.Date = Convert.ToDateTime(txtDate.Text);
            rpt.RefNo1 = txtBillNo.Text;
            rpt.RefNo2 = txtRefNo2.Text;
            rpt.ClinicID = UA.ClinicID.ToString();

            rpt.InsertReceiptHeader();

            string values = HiddenField1.Value;            
            string[] Invalue = values.Split('|');
            int len= Invalue.Length;
            len = len - 1;
           
           
            for (int i = 0; i <len ; i = i + 5)
            {
                ReceiptDetails rptdt = new ReceiptDetails();
                rptdt.MedicineName = Invalue[i];
                rptdt.QTY= Convert.ToInt32(Invalue[i + 4]);
                rptdt.Unit = Invalue[i+1];
                rptdt.CreatedBy = UA.userName;
                rptdt.ClinicID = UA.ClinicID.ToString();
                rptdt.ReceiptID = rpt.ReceiptID;
                                     
                rptdt.InsertReceiptDetails();
               
            }


            // to reLOad added DAta To fields
            string str = rpt.ReceiptID.ToString();

            ReloadInsertFields(str);
            

        }