Пример #1
0
    protected void updateMedicine(object sender, GridViewUpdateEventArgs e)
    {
        this.gvMedicine.Columns[1].Visible = true;
        int?   MedicineCatID     = 0;
        int?   MedicineCompanyID = 0;
        string MedicineID        = ((Label)gvMedicine.Rows[e.RowIndex].FindControl("editlblMedicineID")).Text;
        string MedicineName      = ((TextBox)gvMedicine.Rows[e.RowIndex].FindControl("edittxtMedicineName")).Text;
        string Price             = ((TextBox)gvMedicine.Rows[e.RowIndex].FindControl("edittxtPrice")).Text;
        string MedicineCatName   = ((DropDownList)gvMedicine.Rows[e.RowIndex].FindControl("editMedicineCategoryName")).Text;

        //dc.GetMedcineCategoryID(MedicineCatName, ref MedicineCatID);
        dc.GetMedicineCategoryID(MedicineCatName, ref MedicineCatID);
        string MedicineCompanyName = ((DropDownList)gvMedicine.Rows[e.RowIndex].FindControl("editMedicineCompanyName")).Text;

        dc.GetMedicineCompanyID(MedicineCompanyName, ref MedicineCompanyID);

        string ManufactureDate = ((TextBox)gvMedicine.Rows[e.RowIndex].FindControl("edittxtManufactureDate")).Text;
        string ExpiryDate      = ((TextBox)gvMedicine.Rows[e.RowIndex].FindControl("edittxtExpiryDate")).Text;
        string Amount          = ((TextBox)gvMedicine.Rows[e.RowIndex].FindControl("edittxtAmount")).Text;
        var    q = from medi in dc.Medicine_In_Stocks
                   where medi.MedicineID == Convert.ToInt32(MedicineID)
                   select medi;

        foreach (Medicine_In_Stock mis in q)
        {
            mis.MedicineName       = MedicineName;
            mis.Price              = Convert.ToDecimal(Price);
            mis.MedicineCategoryID = MedicineCatID;
            mis.MedicineCompanyID  = MedicineCompanyID;
            mis.ManufactureDate    = Convert.ToDateTime(ManufactureDate);
            mis.ExpiryDate         = Convert.ToDateTime(ExpiryDate);
            mis.Amount             = Convert.ToDecimal(Amount);
        }
        try
        {
            dc.SubmitChanges();
        }
        catch (Exception ex)
        {
            lblerr.Text = ex.ToString();
        }
        gvMedicine.EditIndex = -1;
        BindGridDataMedicine();
    }
Пример #2
0
    void placeOrder(string name, string quantity)
    {
        int?   MedicineCompanyID   = 0;
        string MedicineCompanyName = ddlMedicineCompany.SelectedItem.Text;
        int?   MedicineID          = 0;

        dc.GetMedicineID(name, ref MedicineID);
        dc.GetMedicineCompanyID(MedicineCompanyName, ref MedicineCompanyID);
        if (chk1 == 1)
        {
            var username = (from a in dc.Users
                            where a.UserId == Convert.ToInt32(Session["AdminUserID"])
                            select a.Username).Single();
            Order_To_Medicine_Company obms = new Order_To_Medicine_Company
            {
                MedicineCompanyID = MedicineCompanyID,
                Due_Date          = Convert.ToDateTime(txtDueDate.Text),
                Order_Date        = DateTime.Now,
                Placed_By         = Convert.ToString(username),
                Status            = "Pending"
            };
            dc.Order_To_Medicine_Companies.InsertOnSubmit(obms);
            dc.SubmitChanges();
        }
        var s = dc.Order_To_Medicine_Companies
                .OrderByDescending(m => m.OrderIDToMC)
                .FirstOrDefault();
        Order_To_Medicine_Company_Per_Medicine obmsm = new Order_To_Medicine_Company_Per_Medicine
        {
            MedicineID  = MedicineID,
            Amount      = Convert.ToInt32(quantity),
            OrderIDToMC = Convert.ToDecimal(s.OrderIDToMC)
        };

        dc.Order_To_Medicine_Company_Per_Medicines.InsertOnSubmit(obmsm);
        dc.SubmitChanges();
    }