public Dictionary <string, object> SaveStatus(pim_spotd Record)
        {
            Dictionary <string, object> RetData = new Dictionary <string, object>();
            Boolean retvalue = false;

            try
            {
                Con_Oracle = new DBConnection();
                DBRecord Rec = new DBRecord();
                Rec.CreateRow("pim_spotd", "EDIT", "spotd_pkid", Record.spotd_pkid);
                Rec.InsertString("spotd_status", Record.spotd_status);
                sql = Rec.UpdateRow();
                Con_Oracle.BeginTransaction();
                Con_Oracle.ExecuteNonQuery(sql);
                Con_Oracle.CommitTransaction();
                Con_Oracle.CloseConnection();
                retvalue = true;
            }
            catch (Exception Ex)
            {
                if (Con_Oracle != null)
                {
                    Con_Oracle.RollbackTransaction();
                    Con_Oracle.CloseConnection();
                }
                retvalue = false;
                throw Ex;
            }
            Con_Oracle.CloseConnection();
            RetData.Add("retvalue", retvalue);

            return(RetData);
        }
        public IHttpActionResult SaveDet()
        {
            int islno = 0;
            Dictionary <string, object> RetData = new Dictionary <string, object>();

            try
            {
                Dictionary <string, object> SearchData = new Dictionary <string, object>();
                var       model  = HttpContext.Current.Request.Form["record"];
                pim_spotd record = JsonConvert.DeserializeObject <pim_spotd>(model);
                using (SpotService obj = new SpotService())
                {
                    RetData = obj.SaveDet(record);
                    islno   = Lib.Conv2Integer(RetData["slno"].ToString());
                }
                System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
                for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
                {
                    Lib.UploadFile(hfc[iCnt], record._globalvariables.comp_code, record.spotd_pkid, hfc.Keys[iCnt]);
                }
                return(Ok(RetData));
            }
            catch (Exception Ex)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Ex.Message.ToString())));
            }
        }
Exemplo n.º 3
0
 public IHttpActionResult SaveStatus(pim_spotd Record)
 {
     try
     {
         using (JobService obj = new JobService())
             return(Ok(obj.SaveStatus(Record)));
     }
     catch (Exception Ex)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Ex.Message.ToString())));
     }
 }
        public string AllValidDet(pim_spotd Record)
        {
            string str = "";

            try
            {
                /*
                 *
                 * sql = "select comp_pkid from (";
                 * sql += "select comp_pkid  from companym a where (a.comp_code = '{CODE}')  ";
                 *
                 * sql += ") a where comp_pkid <> '{PKID}'";
                 *
                 *
                 * if (Con_Oracle.IsRowExists(sql))
                 *  str = "Code/Name Exists";
                 */
            }
            catch (Exception Ex)
            {
                str = Ex.Message.ToString();
            }
            return(str);
        }
        public Dictionary <string, object> GetRecord(Dictionary <string, object> SearchData)
        {
            Dictionary <string, object> RetData = new Dictionary <string, object>();

            List <pim_spotd> mList = new List <pim_spotd>();

            pim_spot  mRow  = new pim_spot();
            pim_spotd mRowd = new pim_spotd();

            string id        = SearchData["pkid"].ToString();
            string comp_code = SearchData["comp_code"].ToString();

            string ServerImageUrl = Lib.GetSeverImageURL(comp_code);

            string sql2 = "";

            try
            {
                DataTable Dt_Rec    = new DataTable();
                DataTable Dt_RecDet = new DataTable();

                sql  = "select  spot_pkid, spot_slno, spot_date, ";
                sql += " spot_store_id, store.comp_name as spot_store_name, ";
                sql += " spot_vendor_id, vendor.comp_name as spot_vendor_name, ";
                sql += " spot_job_remarks, spot_store_contact_name, spot_store_contact_tel,am_status ";
                sql += " from pim_spotm a  ";
                sql += " left join approvalm on spot_pkid =  am_pkid";
                sql += " left join companym store on a.spot_store_id = store.comp_pkid ";
                sql += " left join companym vendor on a.spot_vendor_id = vendor.comp_pkid ";
                sql += " where spot_pkid = '" + id + "'";


                sql2  = "select  spotd_pkid, spotd_parent_id, spotd_name ,spotd_slno,spotd_uom, spotd_wd, spotd_ht, ";
                sql2 += " spotd_artwork_id, artwork.param_name as spotd_artwork_name, artwork.param_slno as spotd_artwork_slno,artwork.param_file_name as spotd_artwork_file_name,";
                sql2 += " spotd_product_id, product.param_name as spotd_product_name, ";
                sql2 += " spotd_close_view, spotd_long_view, spotd_final_view, spotd_status ";
                sql2 += " from pim_spotd a  ";
                sql2 += " left join param artwork on a.spotd_artwork_id = artwork.param_pkid ";
                sql2 += " left join param product on a.spotd_product_id = product.param_pkid ";
                sql2 += " where spotd_parent_id = '" + id + "'";
                sql2 += " order by spotd_slno";


                Con_Oracle = new DBConnection();
                Dt_Rec     = Con_Oracle.ExecuteQuery(sql);
                Dt_RecDet  = Con_Oracle.ExecuteQuery(sql2);
                Con_Oracle.CloseConnection();


                foreach (DataRow Dr in Dt_Rec.Rows)
                {
                    mRow           = new pim_spot();
                    mRow.spot_pkid = Dr["spot_pkid"].ToString();

                    if (Dr["spot_date"].Equals(DBNull.Value))
                    {
                        mRow.spot_date = "";
                    }
                    else
                    {
                        mRow.spot_date = Lib.DatetoString(Dr["spot_date"]);
                    }

                    mRow.spot_slno = Lib.Conv2Integer(Dr["spot_slno"].ToString());

                    mRow.spot_store_id   = Dr["spot_store_id"].ToString();
                    mRow.spot_store_name = Dr["spot_store_name"].ToString();

                    mRow.spot_vendor_id   = Dr["spot_vendor_id"].ToString();
                    mRow.spot_vendor_name = Dr["spot_vendor_name"].ToString();

                    mRow.spot_job_remarks = Dr["spot_job_remarks"].ToString();

                    mRow.approved_status = Dr["am_status"].ToString();

                    mRow.spot_store_contact_name = Dr["spot_store_contact_name"].ToString();
                    mRow.spot_store_contact_tel  = Dr["spot_store_contact_tel"].ToString();


                    break;
                }

                foreach (DataRow Dr in Dt_RecDet.Rows)
                {
                    mRowd                 = new pim_spotd();
                    mRowd.spotd_pkid      = Dr["spotd_pkid"].ToString();
                    mRowd.spotd_parent_id = Dr["spotd_parent_id"].ToString();

                    mRowd.spotd_slno = Lib.Conv2Integer(Dr["spotd_slno"].ToString());
                    mRowd.spotd_name = Dr["spotd_name"].ToString();
                    mRowd.spotd_uom  = Dr["spotd_uom"].ToString();
                    mRowd.spotd_wd   = Lib.Convert2Decimal(Dr["spotd_wd"].ToString());
                    mRowd.spotd_ht   = Lib.Convert2Decimal(Dr["spotd_ht"].ToString());

                    mRowd.spotd_artwork_id        = Dr["spotd_artwork_id"].ToString();
                    mRowd.spotd_artwork_name      = Dr["spotd_artwork_name"].ToString();
                    mRowd.spotd_artwork_file_name = Dr["spotd_artwork_file_name"].ToString();

                    mRowd.spotd_product_id   = Dr["spotd_product_id"].ToString();
                    mRowd.spotd_product_name = Dr["spotd_product_name"].ToString();

                    mRowd.spotd_close_view = Dr["spotd_close_view"].ToString();
                    mRowd.spotd_long_view  = Dr["spotd_long_view"].ToString();
                    mRowd.spotd_final_view = Dr["spotd_final_view"].ToString();

                    mRowd.spotd_close_view_file_uploaded = false;
                    if (Dr["spotd_close_view"].ToString().Length > 0)
                    {
                        mRowd.spotd_close_view_file_uploaded = true;
                    }

                    mRowd.spotd_long_view_file_uploaded = false;
                    if (Dr["spotd_long_view"].ToString().Length > 0)
                    {
                        mRowd.spotd_long_view_file_uploaded = true;
                    }

                    mRowd.spotd_final_view_file_uploaded = false;
                    if (Dr["spotd_final_view"].ToString().Length > 0)
                    {
                        mRowd.spotd_final_view_file_uploaded = true;
                    }

                    mRowd.spotd_status = Dr["spotd_status"].ToString();

                    mRowd.rec_mode = "EDIT";

                    mList.Add(mRowd);
                }
            }
            catch (Exception Ex)
            {
                if (Con_Oracle != null)
                {
                    Con_Oracle.CloseConnection();
                }
                throw Ex;
            }
            RetData.Add("record", mRow);
            RetData.Add("recorddet", mList);
            return(RetData);
        }
        public Dictionary <string, object> SaveDet(pim_spotd Record)
        {
            Dictionary <string, object> RetData = new Dictionary <string, object>();
            string  ErrorMessage = "";
            Boolean retvalue     = false;

            DataTable dt_param = null;

            int iSlno = 0;

            try
            {
                Con_Oracle = new DBConnection();


                if (Record.spotd_name.Trim().Length <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Spot Name Cannot Be Empty");
                }
                if (Record.spotd_uom.Trim().Length <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Unit Cannot Be Empty");
                }
                if (Lib.Conv2Decimal(Record.spotd_wd.ToString()) <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Width Cannot Be Empty");
                }
                if (Lib.Conv2Decimal(Record.spotd_ht.ToString()) <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Height Cannot Be Empty");
                }
                if (Record.spotd_artwork_id.Trim().Length <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "ArtWork Cannot Be Empty");
                }
                if (Record.spotd_product_id.Trim().Length <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Product Cannot Be Empty");
                }


                if (ErrorMessage != "")
                {
                    throw new Exception(ErrorMessage);
                }

                if ((ErrorMessage = AllValidDet(Record)) != "")
                {
                    throw new Exception(ErrorMessage);
                }

                //sql = " select param_slno,param_file_name from param where param_pkid = '" + Record.spot_artwork_id + "'";
                //dt_param = Con_Oracle.ExecuteQuery(sql);

                if (Record.rec_mode == "ADD")
                {
                    sql   = "select isnull(max(spotd_slno), 0) + 1  as slno from pim_spotd where ";
                    sql  += " spotd_parent_id = '" + Record.spotd_parent_id + "'";
                    iSlno = Lib.Conv2Integer(Con_Oracle.ExecuteScalar(sql).ToString());
                }
                else
                {
                    iSlno = Record.spotd_slno;
                }

                if (iSlno <= 0)
                {
                    throw new Exception("Invalid SL#");
                }


                DBRecord Rec = new DBRecord();
                Rec.CreateRow("pim_spotd", Record.rec_mode, "spotd_pkid", Record.spotd_pkid);
                Rec.InsertString("spotd_name", Record.spotd_name);
                Rec.InsertString("spotd_uom", Record.spotd_uom);
                Rec.InsertNumeric("spotd_wd", Record.spotd_wd.ToString());
                Rec.InsertNumeric("spotd_ht", Record.spotd_ht.ToString());
                Rec.InsertString("spotd_artwork_id", Record.spotd_artwork_id);
                Rec.InsertString("spotd_product_id", Record.spotd_product_id);
                Rec.InsertString("spotd_close_view", Record.spotd_close_view);
                Rec.InsertString("spotd_long_view", Record.spotd_long_view);
                Rec.InsertString("spotd_final_view", Record.spotd_final_view);

                if (Record.rec_mode == "ADD")
                {
                    Rec.InsertString("spotd_parent_id", Record.spotd_parent_id);
                    Rec.InsertNumeric("spotd_slno", iSlno.ToString());
                    Rec.InsertString("rec_company_code", Record._globalvariables.comp_code);
                    Rec.InsertString("rec_created_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_created_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_created_date", "GETDATE()");
                    }
                }
                if (Record.rec_mode == "EDIT")
                {
                    Rec.InsertString("rec_edited_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_edited_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_edited_date", "GETDATE()");
                    }
                }

                sql = Rec.UpdateRow();

                Con_Oracle.BeginTransaction();
                Con_Oracle.ExecuteNonQuery(sql);
                Con_Oracle.CommitTransaction();
                Con_Oracle.CloseConnection();
                retvalue = true;
            }
            catch (Exception Ex)
            {
                if (Con_Oracle != null)
                {
                    Con_Oracle.RollbackTransaction();
                    Con_Oracle.CloseConnection();
                }
                retvalue = false;
                throw Ex;
            }
            Con_Oracle.CloseConnection();
            RetData.Add("retvalue", retvalue);
            RetData.Add("slno", iSlno);

            return(RetData);
        }