Exemplo n.º 1
0
        public int insertGrpDA(BusinessEntitiesBS.GroupEntities.grpObj grpObjDa)
        {
            try
            {
                SqlParameter[] sqlParams = new SqlParameter[7];

                //Catgory parameters
                sqlParams[0] = new SqlParameter("@grpName", grpObjDa.grpName);
                sqlParams[1] = new SqlParameter("@grpDesc", grpObjDa.grpDesc);
                sqlParams[2] = new SqlParameter("@grpSts", grpObjDa.grpStatus);
                sqlParams[3] = new SqlParameter("@grpBR", grpObjDa.grpBR);
                sqlParams[4] = new SqlParameter("@grpNR", grpObjDa.grpNR);
                sqlParams[5] = new SqlParameter("@grpChk", grpObjDa.fixedGrp);
                sqlParams[6] = new SqlParameter("@grpQty", grpObjDa.Quantity);

                DataTable idDt       = DBHelper.ExecuteDataset(DBCommon.ConnectionString, "USP_INSERT_GROUP", sqlParams).Tables[0];
                int       returnedId = Convert.ToInt32(idDt.Rows[0].ItemArray[0].ToString());



                SqlParameter[] grpSqlParams = new SqlParameter[3];
                grpSqlParams[0] = new SqlParameter("@grpID", returnedId);
                grpSqlParams[1] = new SqlParameter("@separator", ",");
                grpSqlParams[2] = new SqlParameter("@Array", grpObjDa.itemIdStr);

                int retItemGrp = DBHelper.ExecuteNonQuery(DBCommon.ConnectionString, "ParseArray", grpSqlParams);

                if (idDt.Rows.Count > 0 && retItemGrp == -1)
                {
                    return(returnedId);
                }
                else
                {
                    return(-1);
                }
            }
            catch (SqlException exc)
            {
                return(-1);

                throw exc;
            }
        }
Exemplo n.º 2
0
        protected void grpSubmitBtn_Click(object sender, EventArgs e)
        {
            if (grpImageFU.FileName != string.Empty && grpImageFU.FileContent.Length <= 1024000)
            {
                //bool flagItem;
                float billedrate = 0, netrate = 0;

                DataTable  grpItemsDt = new DataTable();
                DataColumn dc         = new DataColumn("GrpItem", typeof(int));
                grpItemsDt.Columns.Add(dc);

                foreach (GridViewRow dRow in SelectedItemGrid.Rows)
                {
                    string nrate = dRow.Cells[4].Text.ToString();
                    string brate = dRow.Cells[3].Text.ToString();
                    billedrate += float.Parse(brate);
                    netrate    += float.Parse(nrate);

                    int itemId = Convert.ToInt32(dRow.Cells[0].Text.ToString());

                    DataRow dr = grpItemsDt.NewRow();
                    dr[0] = itemId;

                    grpItemsDt.Rows.Add(dr);
                }

                string grpItemString = "";
                bool   first         = true;
                if (grpItemsDt.Rows.Count > 0)
                {
                    foreach (DataRow iRow in grpItemsDt.Rows)
                    {
                        if (first)
                        {
                            grpItemString += int.Parse(iRow["GrpItem"].ToString());
                            first          = false;
                        }
                        else
                        {
                            grpItemString += "," + int.Parse(iRow["GrpItem"].ToString());
                        }
                    }

                    float discount = float.Parse(grpDiscountTxt.Text);
                    billedrate -= (billedrate * (discount / 100));
                    netrate     = (netrate - (netrate * (discount / 100)));

                    BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj();

                    grpValus.grpName = grpNameTxt.Text.ToString();
                    grpValus.grpDesc = grpDescTxt.Text.ToString();
                    grpValus.grpBR   = billedrate;
                    grpValus.grpNR   = netrate;
                    //grpValus.grpBR =  float.Parse(grpBrTxt.Text.ToString());
                    //grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString());
                    grpValus.grpStatus = grpCb.Checked;
                    grpValus.fixedGrp  = grpStatusCb.Checked;
                    grpValus.Quantity  = Int32.Parse(grpQtyTxt.Text.ToString());
                    //item string
                    grpValus.itemIdStr = grpItemString;

                    IAdmin insertGroup = new AdminItems();
                    int    grpId       = insertGroup.insertGroup(grpValus);
                    if (grpId != -1)
                    {
                        //create folder for item images and save images. show result
                        string NewDir = Server.MapPath("~/GroupImages/" + "/" + grpId);
                        try
                        {
                            // Check if directory exists
                            if (!Directory.Exists(NewDir))
                            {
                                // Create the directory.
                                Directory.CreateDirectory(NewDir);
                            }
                        }
                        catch (IOException _ex)
                        {
                            grpMsgLbl.Text = HardCodedValues.BuddaResource.FloderError + _ex.Message;
                        }
                        string filename = grpId + "Photo.jpg";
                        grpImageFU.SaveAs(Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename);

                        string filePath          = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename;
                        string newfileMed        = grpId + "Photomedium.jpg";
                        string newfileSmall      = grpId + "small.jpg";
                        string resizedImageMed   = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileMed;
                        string resizedImageSmall = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileSmall;
                        System.Drawing.Image img = System.Drawing.Image.FromFile(filePath);

                        System.Drawing.Bitmap bmpD = img as Bitmap;

                        Bitmap bmpDriverMed = new Bitmap(bmpD, 500, 500);
                        bmpDriverMed.Save(resizedImageMed, System.Drawing.Imaging.ImageFormat.Jpeg);

                        Bitmap bmpDriverSmall = new Bitmap(bmpD, 150, 150);
                        bmpDriverSmall.Save(resizedImageSmall, System.Drawing.Imaging.ImageFormat.Jpeg);

                        grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupAdd;
                    }
                    else
                    {
                        grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupNotAdded;
                    }
                }
                else
                {
                    grpMsgLbl.Text = HardCodedValues.BuddaResource.ItemSelect;
                }
            }
            else
            {
                grpMsgLbl.Text = HardCodedValues.BuddaResource.ImageSizeError;
            }
            ClearCache();
        }
Exemplo n.º 3
0
        public int insertGroup(BusinessEntitiesBS.GroupEntities.grpObj grpObj)
        {
            IAdminDA inertGrp = new DataAccessBS.AdminClasses.AdminDA();

            return(inertGrp.insertGrpDA(grpObj));
        }
Exemplo n.º 4
0
        protected void grpSubmitBtn_Click(object sender, EventArgs e)
        {
            if (grpImageFU.FileName != string.Empty && grpImageFU.FileContent.Length <= 1024000)
            {
                //bool flagItem;
                float billedrate = 0, netrate = 0;

                DataTable grpItemsDt = new DataTable();
                DataColumn dc = new DataColumn("GrpItem", typeof(int));
                grpItemsDt.Columns.Add(dc);

                foreach (GridViewRow dRow in SelectedItemGrid.Rows)
                {
                    string nrate = dRow.Cells[4].Text.ToString();
                    string brate = dRow.Cells[3].Text.ToString();
                    billedrate += float.Parse(brate);
                    netrate += float.Parse(nrate);

                    int itemId = Convert.ToInt32(dRow.Cells[0].Text.ToString());

                    DataRow dr = grpItemsDt.NewRow();
                    dr[0] = itemId;

                    grpItemsDt.Rows.Add(dr);
                }

                string grpItemString = "";
                bool first = true;
                if (grpItemsDt.Rows.Count > 0)
                {
                    foreach (DataRow iRow in grpItemsDt.Rows)
                    {
                        if (first)
                        {
                            grpItemString += int.Parse(iRow["GrpItem"].ToString());
                            first = false;
                        }
                        else
                        {
                            grpItemString += "," + int.Parse(iRow["GrpItem"].ToString());
                        }

                    }

                    float discount = float.Parse(grpDiscountTxt.Text);
                    billedrate -= (billedrate * (discount / 100));
                    netrate = (netrate - (netrate * (discount / 100)));

                    BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj();

                    grpValus.grpName = grpNameTxt.Text.ToString();
                    grpValus.grpDesc = grpDescTxt.Text.ToString();
                    grpValus.grpBR = billedrate;
                    grpValus.grpNR = netrate;
                    //grpValus.grpBR =  float.Parse(grpBrTxt.Text.ToString());
                    //grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString());
                    grpValus.grpStatus = grpCb.Checked;
                    grpValus.fixedGrp = grpStatusCb.Checked;
                    grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString());
                    //item string
                    grpValus.itemIdStr = grpItemString;

                    IAdmin insertGroup = new AdminItems();
                    int grpId = insertGroup.insertGroup(grpValus);
                    if (grpId != -1)
                    {
                        //create folder for item images and save images. show result
                        string NewDir = Server.MapPath("~/GroupImages/" + "/" + grpId);
                        try
                        {
                            // Check if directory exists
                            if (!Directory.Exists(NewDir))
                            {
                                // Create the directory.
                                Directory.CreateDirectory(NewDir);
                            }
                        }
                        catch (IOException _ex)
                        {
                            grpMsgLbl.Text = HardCodedValues.BuddaResource.FloderError + _ex.Message;
                        }
                        string filename = grpId + "Photo.jpg";
                        grpImageFU.SaveAs(Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename);

                        string filePath = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename;
                        string newfileMed = grpId + "Photomedium.jpg";
                        string newfileSmall = grpId + "small.jpg";
                        string resizedImageMed = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileMed;
                        string resizedImageSmall = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileSmall;
                        System.Drawing.Image img = System.Drawing.Image.FromFile(filePath);

                        System.Drawing.Bitmap bmpD = img as Bitmap;

                        Bitmap bmpDriverMed = new Bitmap(bmpD, 500, 500);
                        bmpDriverMed.Save(resizedImageMed, System.Drawing.Imaging.ImageFormat.Jpeg);

                        Bitmap bmpDriverSmall = new Bitmap(bmpD, 150, 150);
                        bmpDriverSmall.Save(resizedImageSmall, System.Drawing.Imaging.ImageFormat.Jpeg);

                        grpMsgLbl.Text =HardCodedValues.BuddaResource.GroupAdd;

                    }
                    else
                    {
                        grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupNotAdded;
                    }
                }
                else
                {
                    grpMsgLbl.Text = HardCodedValues.BuddaResource.ItemSelect;
                }
            }
            else
            {
                grpMsgLbl.Text = HardCodedValues.BuddaResource.ImageSizeError;
            }
            ClearCache();
        }
Exemplo n.º 5
0
        protected void grpSubmitBtn_Click(object sender, EventArgs e)
        {
            bool flagItem;

            DataTable  grpItemsDt = new DataTable();
            DataColumn dc         = new DataColumn("GrpItem", typeof(int));

            grpItemsDt.Columns.Add(dc);


            foreach (GridViewRow dRow in itemGrid.Rows)
            {
                flagItem = (dRow.FindControl("itemChkBox") as CheckBox).Checked;

                if (flagItem)
                {
                    int itemId = Convert.ToInt32(itemGrid.DataKeys[dRow.RowIndex].Value);

                    DataRow dr = grpItemsDt.NewRow();
                    dr[0] = itemId;

                    grpItemsDt.Rows.Add(dr);
                }
            }

            string grpItemString = "";
            bool   first         = true;

            if (grpItemsDt.Rows.Count > 0)
            {
                foreach (DataRow iRow in grpItemsDt.Rows)
                {
                    if (first)
                    {
                        grpItemString += int.Parse(iRow["GrpItem"].ToString());
                        first          = false;
                    }
                    else
                    {
                        grpItemString += "," + int.Parse(iRow["GrpItem"].ToString());
                    }
                }

                BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj();

                grpValus.grpName   = grpNameTxt.Text.ToString();
                grpValus.grpDesc   = grpDescTxt.Text.ToString();
                grpValus.grpBR     = float.Parse(grpBrTxt.Text.ToString());
                grpValus.grpNR     = float.Parse(grpNrTxt.Text.ToString());
                grpValus.grpStatus = grpCb.Checked;
                grpValus.fixedGrp  = grpStatusCb.Checked;
                grpValus.Quantity  = Int32.Parse(grpQtyTxt.Text.ToString());
                //item string
                grpValus.itemIdStr = grpItemString;

                IAdmin insertGroup = new AdminItems();
                int    grpId       = insertGroup.insertGroup(grpValus);
                if (grpId != -1)
                {
                    grpMsgLbl.Text = "Group Inserted";
                }
                else
                {
                    grpMsgLbl.Text = "Error Occured! Group not inserted";
                }
            }
            else
            {
                grpMsgLbl.Text = "Select items for the group";
            }
        }
Exemplo n.º 6
0
        protected void grpSubmitBtn_Click(object sender, EventArgs e)
        {
            bool flagItem;

            DataTable grpItemsDt = new DataTable();
            DataColumn dc = new DataColumn("GrpItem", typeof(int));
            grpItemsDt.Columns.Add(dc);

            foreach (GridViewRow dRow in itemGrid.Rows)
            {

             flagItem = (dRow.FindControl("itemChkBox") as CheckBox).Checked;

                if (flagItem)
                 {
                     int itemId = Convert.ToInt32(itemGrid.DataKeys[dRow.RowIndex].Value);

                     DataRow dr = grpItemsDt.NewRow();
                     dr[0] = itemId;

                     grpItemsDt.Rows.Add(dr);

                 }

            }

            string grpItemString = "";
            bool first = true;
            if (grpItemsDt.Rows.Count > 0)
            {
                foreach (DataRow iRow in grpItemsDt.Rows)
                {
                    if (first)
                    {
                        grpItemString += int.Parse(iRow["GrpItem"].ToString());
                        first = false;
                    }
                    else
                    {
                        grpItemString += "," + int.Parse(iRow["GrpItem"].ToString());
                    }

                }

                BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj();

                grpValus.grpName = grpNameTxt.Text.ToString();
                grpValus.grpDesc = grpDescTxt.Text.ToString();
                grpValus.grpBR =  float.Parse(grpBrTxt.Text.ToString());
                grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString());
                grpValus.grpStatus = grpCb.Checked;
                grpValus.fixedGrp = grpStatusCb.Checked;
                grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString());
                //item string
                grpValus.itemIdStr = grpItemString;

                IAdmin insertGroup = new AdminItems();
                int grpId = insertGroup.insertGroup(grpValus);
                if (grpId != -1)
                {
                    grpMsgLbl.Text = "Group Inserted";
                }
                else
                {
                    grpMsgLbl.Text = "Error Occured! Group not inserted";
                }
            }
            else
            {
                grpMsgLbl.Text = "Select items for the group";
            }
        }